This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

mktime.c fixes (part 2 of 6): don't reject pre-1969 timestamps


This patch undoes a hack installed in glibc's version of mktime in
April 2002, which attempts to reject time stamps before the epoch.  As
far as I can see, that hack was to work around boundary-condition bugs
in mktime, near extremal time values.  Unfortunately the hack doesn't
work correctly, as it rejects some valid time stamps (e.g., the 25th
month of 1968).  Also, some other boundary-condition bugs still occur,
near maximal time values, so the hack didn't suffice anyway.  I'm
about to send you patches that fix the bugs in a different way, so
this hack won't be needed.


2003-12-30  Paul Eggert  <eggert@twinsun.com>

	* time/mktime.c (__mktime_internal):
	Do not reject timestamps before 1969 arbitrarily,
	as POSIX requires that mktime work on timestamps like "1968-25-01
	00:00:00 +0000".  This undoes the changes in glibc time/mktime.c
	revisions 1.47 through 1.49 (April 2002).  Most likely those changes
	were to work around a bug that is fixed in a different way in a
	subsequent patch.

===================================================================
RCS file: RCS/mktime.c,v
retrieving revision 1.51.0.1
retrieving revision 1.51.0.2
diff -pu -r1.51.0.1 -r1.51.0.2
--- mktime.c	2003/12/31 05:10:34	1.51.0.1
+++ mktime.c	2003/12/31 05:38:51	1.51.0.2
@@ -237,12 +237,6 @@ __mktime_internal (struct tm *tp,
 
   int sec_requested = sec;
 
-  /* Only years after 1970 are defined.
-     If year is 69, it might still be representable due to
-     timezone differences.  */
-  if (year < 69)
-    return -1;
-
 #if LEAP_SECONDS_POSSIBLE
   /* Handle out-of-range seconds specially,
      since ydhms_tm_diff assumes every minute has 60 seconds.  */
@@ -347,14 +341,6 @@ __mktime_internal (struct tm *tp,
       const time_t time_t_min = TIME_T_MIN;
 
       if (time_t_max / 3 - time_t_min / 3 < (dsec < 0 ? - dsec : dsec))
-	return -1;
-    }
-
-  if (year == 69)
-    {
-      /* If year was 69, need to check whether the time was representable
-	 or not.  */
-      if (t < 0 || t > 2 * 24 * 60 * 60)
 	return -1;
     }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]