From: Amos Jeffries Date: Wed, 20 Oct 2010 06:06:14 +0000 (-0600) Subject: Author: Alex Rousskov X-Git-Tag: SQUID_3_1_9~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=615d54b2a561a3e94388d61ac18a71c9dda7a5c4;p=thirdparty%2Fsquid.git Author: Alex Rousskov 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 dd98d360ae..1acf5d107e 100644 --- a/lib/rfc1123.c +++ b/lib/rfc1123.c @@ -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);