Bug 559618. Treat negative max-age values as 0. r=jduell
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 26 Apr 2010 16:27:01 -0400
changeset 34374 db21370ca1cccec4d1df6d28704723347e31051f
parent 34373 f2adbb501cd98dfc46f545e95cd080c765f64285
child 34375 7dca7be78aad3eac42f1b42126a4d29de8cbc5ae
push id1424
push userbzbarsky@mozilla.com
push dateFri, 25 Jun 2010 04:30:36 +0000
reviewersjduell
bugs559618
milestone1.9.2.6pre
Bug 559618. Treat negative max-age values as 0. r=jduell
netwerk/protocol/http/src/nsHttpResponseHead.cpp
--- a/netwerk/protocol/http/src/nsHttpResponseHead.cpp
+++ b/netwerk/protocol/http/src/nsHttpResponseHead.cpp
@@ -530,17 +530,20 @@ nsHttpResponseHead::GetMaxAgeValue(PRUin
     const char *val = PeekHeader(nsHttp::Cache_Control);
     if (!val)
         return NS_ERROR_NOT_AVAILABLE;
 
     const char *p = PL_strcasestr(val, "max-age=");
     if (!p)
         return NS_ERROR_NOT_AVAILABLE;
 
-    *result = (PRUint32) atoi(p + 8);
+    int maxAgeValue = atoi(p + 8);
+    if (maxAgeValue < 0)
+        maxAgeValue = 0;
+    *result = PRUint32(maxAgeValue);
     return NS_OK;
 }
 
 nsresult
 nsHttpResponseHead::GetExpiresValue(PRUint32 *result)
 {
     const char *val = PeekHeader(nsHttp::Expires);
     if (!val)