mktime.c: normalize tp->tm_isdst value to -1/0/1.
authorUlrich Drepper <drepper@redhat.com>
Wed, 23 Jul 2008 14:19:15 +0000 (16:19 +0200)
committerJim Meyering <meyering@redhat.com>
Wed, 23 Jul 2008 14:20:54 +0000 (16:20 +0200)
* lib/mktime.c (__mktime_internal): Normalize tp->tm_isdst value.
Reported by Michael Ringe <Michael.Ringe@gmx.de> in
<http://sourceware.org/bugzilla/show_bug.cgi?id=6723>.

ChangeLog
lib/mktime.c

index 97f6c76..6c48308 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2008-07-23  Ulrich Drepper  <drepper@redhat.com>
 
+       mktime.c: normalize tp->tm_isdst value to -1/0/1.
+       * lib/mktime.c (__mktime_internal): Normalize tp->tm_isdst value.
+       Reported by Michael Ringe <Michael.Ringe@gmx.de> in
+       <http://sourceware.org/bugzilla/show_bug.cgi?id=6723>.
+
        * lib/canonicalize-lgpl.c (__realpath): Avoid buffer overflow after
        readlink on platforms without PATH_MAX.
 
index a91fb20..f9e7b60 100644 (file)
@@ -290,7 +290,9 @@ __mktime_internal (struct tm *tp,
   int mday = tp->tm_mday;
   int mon = tp->tm_mon;
   int year_requested = tp->tm_year;
-  int isdst = tp->tm_isdst;
+  /* Normalize the value.  */
+  int isdst = ((tp->tm_isdst >> (8 * sizeof (tp->tm_isdst) - 1))
+              | (tp->tm_isdst != 0));
 
   /* 1 if the previous probe was DST.  */
   int dst2;