|
|
dd59ef |
From a10acfb1d2118f9a180181d3fed5399dbbe1df3c Mon Sep 17 00:00:00 2001
|
|
|
dd59ef |
From: Pádraig Brady <P@draigBrady.com>
|
|
|
dd59ef |
Date: Tue, 25 Feb 2014 10:58:48 +0000
|
|
|
dd59ef |
Subject: parse-datetime: fix crash or infloop in TZ="" parsing
|
|
|
dd59ef |
|
|
|
dd59ef |
This was reported in http://bugs.gnu.org/16872
|
|
|
dd59ef |
from the coreutils command: date -d 'TZ="""'
|
|
|
dd59ef |
|
|
|
dd59ef |
The infinite loop for this case was present since the
|
|
|
dd59ef |
initial TZ="" parsing support in commit de95bdc2 29-10-2004.
|
|
|
dd59ef |
This was changed to a crash or heap corruption depending
|
|
|
dd59ef |
on the platform with commit 2e3e4195 18-01-2010.
|
|
|
dd59ef |
|
|
|
dd59ef |
* lib/parse-datetime.y (parse_datetime): Break out of the
|
|
|
dd59ef |
TZ="" parsing loop once the second significant " is found.
|
|
|
dd59ef |
Also skip over any subsequent whitespace to be consistent
|
|
|
dd59ef |
with the non TZ= case.
|
|
|
dd59ef |
---
|
|
|
dd59ef |
diff --git a/lib/parse-datetime.y b/lib/parse-datetime.y
|
|
|
dd59ef |
index 6ece765..0ba0a52 100644
|
|
|
dd59ef |
--- a/lib/parse-datetime.y
|
|
|
dd59ef |
+++ b/lib/parse-datetime.y
|
|
|
dd59ef |
@@ -1303,8 +1303,6 @@ parse_datetime (struct timespec *result, char const *p,
|
|
|
dd59ef |
char tz1buf[TZBUFSIZE];
|
|
|
dd59ef |
bool large_tz = TZBUFSIZE < tzsize;
|
|
|
dd59ef |
bool setenv_ok;
|
|
|
dd59ef |
- /* Free tz0, in case this is the 2nd or subsequent time through. */
|
|
|
dd59ef |
- free (tz0);
|
|
|
dd59ef |
tz0 = get_tz (tz0buf);
|
|
|
dd59ef |
z = tz1 = large_tz ? xmalloc (tzsize) : tz1buf;
|
|
|
dd59ef |
for (s = tzbase; *s != '"'; s++)
|
|
|
dd59ef |
@@ -1316,7 +1314,12 @@ parse_datetime (struct timespec *result, char const *p,
|
|
|
dd59ef |
if (!setenv_ok)
|
|
|
dd59ef |
goto fail;
|
|
|
dd59ef |
tz_was_altered = true;
|
|
|
dd59ef |
+
|
|
|
dd59ef |
p = s + 1;
|
|
|
dd59ef |
+ while (c = *p, c_isspace (c))
|
|
|
dd59ef |
+ p++;
|
|
|
dd59ef |
+
|
|
|
dd59ef |
+ break;
|
|
|
dd59ef |
}
|
|
|
dd59ef |
}
|
|
|
dd59ef |
|
|
|
dd59ef |
--
|
|
|
dd59ef |
cgit v0.9.0.2
|