From: Alex Rousskov Date: Wed, 22 Sep 2010 23:09:58 +0000 (-0600) Subject: HTTP Compliance: Make date parser stricter to better handle malformed Expires. X-Git-Tag: take1~235 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1bcd740baa79eb64a2c8d47b91a47805e856fd5e;p=thirdparty%2Fsquid.git 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 --- diff --git a/lib/rfc1123.c b/lib/rfc1123.c index 8b9658a8e4..91c588dc17 100644 --- a/lib/rfc1123.c +++ b/lib/rfc1123.c @@ -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);