From: Fabian Keil <fk@fabiankeil.de>
Date: Sun, 4 Sep 2011 11:32:20 +0000 (+0000)
Subject: In parse_header_time(), add a sanity check for GNU libc's strptime() which apparently... 
X-Git-Tag: v_3_0_18~110
X-Git-Url: http://www.privoxy.org/gitweb/%22https:/static/@default-cgi@toggle?a=commitdiff_plain;h=e59766778d6b05c1bffb89f18cefa888a8f5ff40;p=privoxy.git

In parse_header_time(), add a sanity check for GNU libc's strptime() which apparently occasionally returns negative years.

Reported by Väinö in #3403560
---

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;
       }