From: Fabian Keil <fk@fabiankeil.de>
Date: Sun, 4 Sep 2011 11:33:06 +0000 (+0000)
Subject: Let parse_header_time() look for two-digit years first
X-Git-Tag: v_3_0_18~109
X-Git-Url: http://www.privoxy.org/gitweb/%22https:/faq/@default-cgi@/user-manual/static/coding.html?a=commitdiff_plain;h=22ab3219f632f2dc4c4323ee6daca13ff3ac19b6;p=privoxy.git

Let parse_header_time() look for two-digit years first

Should work around GNU libc's strptime() reporting negative
years when parsing a two-digit year with %Y.

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

diff --git a/parsers.c b/parsers.c
index ce76dc7c..6e9645e3 100644
--- a/parsers.c
+++ b/parsers.c
@@ -1,4 +1,4 @@
-const char parsers_rcs[] = "$Id: parsers.c,v 1.229 2011/09/04 11:31:45 fabiankeil Exp $";
+const char parsers_rcs[] = "$Id: parsers.c,v 1.230 2011/09/04 11:32:20 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/parsers.c,v $
@@ -4008,13 +4008,18 @@ int strclean(char *string, const char *substring)
 static jb_err parse_header_time(const char *header_time, time_t *result)
 {
    struct tm gmt;
+   /*
+    * Checking for two-digit years first in an
+    * attempt to work around GNU libc's strptime()
+    * reporting negative year values when using %Y.
+    */
    static const char *time_formats[] = {
+      /* Tue, 02-Jun-37 20:00:00 */
+      "%a, %d-%b-%y %H:%M:%S",
       /* Tue, 02 Jun 2037 20:00:00 */
       "%a, %d %b %Y %H:%M:%S",
       /* Tue, 02-Jun-2037 20:00:00 */
       "%a, %d-%b-%Y %H:%M:%S",
-      /* Tue, 02-Jun-37 20:00:00 */
-      "%a, %d-%b-%y %H:%M:%S",
       /* Tuesday, 02-Jun-2037 20:00:00 */
       "%A, %d-%b-%Y %H:%M:%S",
       /* Tuesday Jun 02 20:00:00 2037 */