bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gnulib] mktime fix for Debian bug #177940


From: Paul Eggert
Subject: [Bug-gnulib] mktime fix for Debian bug #177940
Date: 04 Jun 2003 23:47:03 -0700
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

I installed this patch:

2003-06-04  Paul Eggert  <address@hidden>

        * mktime.c: Fix Debian bug 177940
        <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=177940>.
        (localtime_offset): Now long int, not time_t, because we want it
        to be guaranteed to be signed.  All uses changed.
        (__mktime_internal): If overflow would occur when adding offset,
        don't add it.

Index: mktime.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/mktime.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -p -u -r1.36 -r1.37
--- mktime.c    4 Jun 2003 20:09:48 -0000       1.36
+++ mktime.c    5 Jun 2003 06:43:15 -0000       1.37
@@ -221,7 +221,7 @@ static
 time_t
 __mktime_internal (struct tm *tp,
                   struct tm *(*convert) (const time_t *, struct tm *),
-                  time_t *offset)
+                  long int *offset)
 {
   time_t t, dt, t0, t1, t2;
   struct tm tm;
@@ -279,8 +279,11 @@ __mktime_internal (struct tm *tp,
   tm.tm_year = EPOCH_YEAR - TM_YEAR_BASE;
   tm.tm_yday = tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
   t0 = ydhms_tm_diff (year, yday, hour, min, sec, &tm);
+  t = t0 + *offset;
+  if ((t < t0) != (*offset < 0))
+    t = t0;
 
-  for (t = t1 = t2 = t0 + *offset, dst2 = 0;
+  for (t1 = t2 = t, dst2 = 0;
        (dt = ydhms_tm_diff (year, yday, hour, min, sec,
                            ranged_convert (convert, &t, &tm)));
        t1 = t2, t2 = t, t += dt, dst2 = tm.tm_isdst != 0)
@@ -376,7 +379,7 @@ __mktime_internal (struct tm *tp,
 }
 
 
-static time_t localtime_offset;
+static long int localtime_offset;
 
 /* Convert *TP to a time_t value.  */
 time_t




reply via email to

[Prev in Thread] Current Thread [Next in Thread]