From e59766778d6b05c1bffb89f18cefa888a8f5ff40 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sun, 4 Sep 2011 11:32:20 +0000 Subject: [PATCH] In parse_header_time(), add a sanity check for GNU libc's strptime() which apparently occasionally returns negative years. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reported by Väinö in #3403560 --- parsers.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/parsers.c b/parsers.c index 7dbaf028..ce76dc7c 100644 --- a/parsers.c +++ b/parsers.c @@ -1,4 +1,4 @@ -const char parsers_rcs[] = "$Id: parsers.c,v 1.228 2011/09/04 11:31:17 fabiankeil Exp $"; +const char parsers_rcs[] = "$Id: parsers.c,v 1.229 2011/09/04 11:31:45 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/parsers.c,v $ @@ -4032,6 +4032,14 @@ static jb_err parse_header_time(const char *header_time, time_t *result) { if (NULL != strptime(header_time, time_formats[i], &gmt)) { + /* Sanity check for GNU libc. */ + if (gmt.tm_year < 0) + { + log_error(LOG_LEVEL_HEADER, + "Failed to parse '%s' using '%s'. Moving on.", + header_time, time_formats[i]); + continue; + } *result = timegm(&gmt); return JB_ERR_OK; } -- 2.39.2