# HG changeset patch # User Paul Eggert # Date 1506388285 25200 # Node ID dbc071f60e30c11f13b063b53fd3551a58673442 # Parent 27408d40c4cc60281b56062f96c98bd9a862e6d8 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. diff -r 27408d40c4cc -r dbc071f60e30 ChangeLog --- a/ChangeLog Mon Sep 25 21:31:25 2017 +0200 +++ b/ChangeLog Mon Sep 25 18:11:25 2017 -0700 @@ -1,3 +1,11 @@ +2017-09-25 Paul Eggert + + 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 vma-iter: Improvements for BSD platforms. diff -r 27408d40c4cc -r dbc071f60e30 lib/parse-datetime.y --- a/lib/parse-datetime.y Mon Sep 25 21:31:25 2017 +0200 +++ b/lib/parse-datetime.y Mon Sep 25 18:11:25 2017 -0700 @@ -2034,7 +2034,13 @@ 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 @@ 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); diff -r 27408d40c4cc -r dbc071f60e30 lib/posixtm.c --- a/lib/posixtm.c Mon Sep 25 21:31:25 2017 +0200 +++ b/lib/posixtm.c Mon Sep 25 18:11:25 2017 -0700 @@ -182,7 +182,12 @@ 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);