]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
mktime: fix bug with Y2038 DST transition
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 15 Nov 2018 21:59:33 +0000 (22:59 +0100)
committerAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>
Thu, 15 Nov 2018 21:59:33 +0000 (22:59 +0100)
[BZ#23789]
* time/mktime.c (ranged_convert): On 32-bit platforms, don’t
mishandle a DST transition that jumps over the Y2038 boundary.
No such DST transitions are known so this is only a theoretical
bug, but we might as well do things right.

ChangeLog
time/mktime.c

index 064d0a305c2ef96785330e9dd1462d05163298d4..d503a3e65f35de7dfcb19b797337b116a2bd23b1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2018-11-15  Paul Eggert  <eggert@cs.ucla.edu>
 
+       mktime: fix bug with Y2038 DST transition
+       [BZ#23789]
+       * time/mktime.c (ranged_convert): On 32-bit platforms, don’t
+       mishandle a DST transition that jumps over the Y2038 boundary.
+       No such DST transitions are known so this is only a theoretical
+       bug, but we might as well do things right.
+
        mktime: make more room for overflow
        [BZ#23789]
        * time/mktime.c (long_int): Now 4⨯ int, not just 3⨯.
index ffbb5ea171457da2e006ebb353c41e9b838348fd..6d5b8cf838798121186f522f7bd1a260e919a2f7 100644 (file)
@@ -323,7 +323,7 @@ ranged_convert (struct tm *(*convert) (const time_t *, struct tm *),
       while (true)
        {
          long_int mid = long_int_avg (ok, bad);
-         if (mid != ok && mid != bad)
+         if (mid == ok || mid == bad)
            break;
          r = convert_time (convert, mid, tp);
          if (r)
@@ -332,6 +332,8 @@ ranged_convert (struct tm *(*convert) (const time_t *, struct tm *),
            bad = mid;
        }
 
+      *t = ok;
+
       if (!r && ok)
        {
          /* The last conversion attempt failed;