]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Alex Rousskov <rousskov@measurement-factory.com>
authorAmos Jeffries <amosjeffries@squid-cache.org>
Wed, 20 Oct 2010 06:06:14 +0000 (00:06 -0600)
committerAmos Jeffries <amosjeffries@squid-cache.org>
Wed, 20 Oct 2010 06:06:14 +0000 (00:06 -0600)
HTTP Compliance: Make date parser stricter to better handle malformed Expires.

Check that there is no zone or zone is "GMT" in parse_date_elements().
Make sure there is no junk at the end of date in parse_date().

This will affect Date, IMS, and other date-carrying header fields recognized
by Squid but should not cause any messages to be rejected. Squid would just
ignore the malformed headers as if they are not there.

Co-Advisor test case:
    test_case/rfc2616/invalidExpiresMakesStale-rfc1123x

lib/rfc1123.c

index dd98d360ae007b4c5ccb370a1163e03be1be168f..1acf5d107ea3c40e3bb6b4e72a7cfbf1bafe4133 100644 (file)
@@ -124,7 +124,7 @@ parse_date_elements(const char *day, const char *month, const char *year,
     char *t;
     memset(&tm, 0, sizeof(tm));
 
-    if (!day || !month || !year || !aTime)
+    if (!day || !month || !year || !aTime || (zone && strcmp(zone, "GMT")))
         return NULL;
     tm.tm_mday = atoi(day);
     tm.tm_mon = make_month(month);
@@ -181,12 +181,16 @@ parse_date(const char *str) {
                 timestr = t;
             else if (!year)
                 year = t;
+            else
+                return NULL;
         } else if (!wday)
             wday = t;
         else if (!month)
             month = t;
         else if (!zone)
             zone = t;
+        else
+            return NULL;
     }
     tm = parse_date_elements(day, month, year, timestr, zone);