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