In parse_header_time(), add a sanity check for GNU libc's strptime() which apparently...
authorFabian Keil <fk@fabiankeil.de>
Sun, 4 Sep 2011 11:32:20 +0000 (11:32 +0000)
committerFabian Keil <fk@fabiankeil.de>
Sun, 4 Sep 2011 11:32:20 +0000 (11:32 +0000)
Reported by Väinö in #3403560

parsers.c

index 7dbaf02..ce76dc7 100644 (file)
--- 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;
       }