about summary refs log tree commit diff
path: root/time
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2018-11-15 22:59:33 +0100
committerAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2018-11-15 22:59:33 +0100
commitf6b3331bbae638d1bb50813fceb429d3b3dc0eb9 (patch)
treedfa7285cb5874f6d95c57f1f0721d568bfd1e3c3 /time
parentefbdddc381cfea5bfa9527e86fa3078257e5d91b (diff)
downloadglibc-f6b3331bbae638d1bb50813fceb429d3b3dc0eb9.tar.gz
glibc-f6b3331bbae638d1bb50813fceb429d3b3dc0eb9.tar.xz
glibc-f6b3331bbae638d1bb50813fceb429d3b3dc0eb9.zip
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.
Diffstat (limited to 'time')
-rw-r--r--time/mktime.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/time/mktime.c b/time/mktime.c
index ffbb5ea171..6d5b8cf838 100644
--- a/time/mktime.c
+++ b/time/mktime.c
@@ -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;