]> Savannah Git Hosting - gnulib.git/commitdiff
parse-datetime, posixtm: avoid uninit access
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 26 Sep 2017 01:11:25 +0000 (18:11 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 26 Sep 2017 01:28:30 +0000 (18:28 -0700)
* lib/parse-datetime.y (parse_datetime2):
* lib/posixtm.c (posixtime):
Do not access uninitialized storage, even though the resulting
value is never used.

ChangeLog
lib/parse-datetime.y
lib/posixtm.c

index 386986ee7ab30be6c2b8f4cf83d345252029890c..9c6d73f72f241994af3251ce64f8f64602a1c70a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2017-09-25  Paul Eggert  <eggert@cs.ucla.edu>
+
+       parse-datetime, posixtm: avoid uninit access
+       * lib/parse-datetime.y (parse_datetime2):
+       * lib/posixtm.c (posixtime):
+       Do not access uninitialized storage, even though the resulting
+       value is never used.
+
 2017-09-25  Bruno Haible  <bruno@clisp.org>
 
        vma-iter: Improvements for BSD platforms.
index 9eff2dc3b926fc899d103591a851abc284f388b2..f8da02d3f3fdbe3dfb1fc3c46bf897c72971fa1c 100644 (file)
@@ -2034,7 +2034,13 @@ parse_datetime2 (struct timespec *result, char const *p,
       if (pc.local_zones_seen)
         tm.tm_isdst = pc.local_isdst;
 
-      tm0 = tm;
+      tm0.tm_sec = tm.tm_sec;
+      tm0.tm_min = tm.tm_min;
+      tm0.tm_hour = tm.tm_hour;
+      tm0.tm_mday = tm.tm_mday;
+      tm0.tm_mon = tm.tm_mon;
+      tm0.tm_year = tm.tm_year;
+      tm0.tm_isdst = tm.tm_isdst;
 
       Start = mktime_z (tz, &tm);
 
@@ -2064,7 +2070,13 @@ parse_datetime2 (struct timespec *result, char const *p,
                     dbg_printf (_("error: tzalloc (\"%s\") failed\n"), tz2buf);
                   goto fail;
                 }
-              tm = tm0;
+              tm.tm_sec = tm0.tm_sec;
+              tm.tm_min = tm0.tm_min;
+              tm.tm_hour = tm0.tm_hour;
+              tm.tm_mday = tm0.tm_mday;
+              tm.tm_mon = tm0.tm_mon;
+              tm.tm_year = tm0.tm_year;
+              tm.tm_isdst = tm0.tm_isdst;
               Start = mktime_z (tz2, &tm);
               repaired = mktime_ok (tz2, &tm0, &tm, Start);
               tzfree (tz2);
index 26a35dd3fc6964415360ebebc93a2e318f7d6af0..030f704f06c5e430654f850f14fbf5882b7b848f 100644 (file)
@@ -182,7 +182,12 @@ posixtime (time_t *p, const char *s, unsigned int syntax_bits)
   if (! posix_time_parse (&tm0, s, syntax_bits))
     return false;
 
-  tm1 = tm0;
+  tm1.tm_sec = tm0.tm_sec;
+  tm1.tm_min = tm0.tm_min;
+  tm1.tm_hour = tm0.tm_hour;
+  tm1.tm_mday = tm0.tm_mday;
+  tm1.tm_mon = tm0.tm_mon;
+  tm1.tm_year = tm0.tm_year;
   tm1.tm_isdst = -1;
   t = mktime (&tm1);