]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
HTTP Compliance: Make date parser stricter to better handle malformed Expires.
authorAlex Rousskov <rousskov@measurement-factory.com>
Wed, 22 Sep 2010 23:09:58 +0000 (17:09 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Wed, 22 Sep 2010 23:09:58 +0000 (17:09 -0600)
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 8b9658a8e49666f9cc88569d993a7046e76829e9..91c588dc17c08e2f398928ead558ffbf2fe90d26 100644 (file)
@@ -113,7 +113,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);
@@ -170,12 +170,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);