]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix 32-bit wrap in refresh_pattern min/max values.
authorAmos Jeffries <amosjeffries@squid-cache.org>
Wed, 18 Aug 2010 01:46:52 +0000 (19:46 -0600)
committerAmos Jeffries <amosjeffries@squid-cache.org>
Wed, 18 Aug 2010 01:46:52 +0000 (19:46 -0600)
Attached patch limits the values to 1 year (arbitrary based on rumours
about good caching times). Checking for 32-bit wrap and setting the max
1 year limit instead of cutting them to zero.

The expected outcome of this is correct cache storage time extension
according to refresh_pattern documentation when people desperately set
min/max to > a million minutes. Instead of a silent always-stale verdict.

src/cache_cf.cc

index 280308d1b9b795f979d3ccb00c8e45b7155c0102..3a7a2a44293a47dd5c85848484570faea767ffc8 100644 (file)
@@ -2327,6 +2327,16 @@ parse_refreshpattern(refresh_t ** head)
 
     i = GetInteger();          /* token: min */
 
+    /* catch negative and insanely huge values close to 32-bit wrap */
+    if (i < 0) {
+        debugs(3, DBG_IMPORTANT, "WARNING: refresh_pattern minimum age negative. Cropped back to zero.");
+        i = 0;
+    }
+    if (i > 60*24*365) {
+        debugs(3, DBG_IMPORTANT, "WARNING: refresh_pattern minimum age too high. Cropped back to 1 year.");
+        i = 60*24*365;
+    }
+
     min = (time_t) (i * 60);   /* convert minutes to seconds */
 
     i = GetInteger();          /* token: pct */
@@ -2335,6 +2345,16 @@ parse_refreshpattern(refresh_t ** head)
 
     i = GetInteger();          /* token: max */
 
+    /* catch negative and insanely huge values close to 32-bit wrap */
+    if (i < 0) {
+        debugs(3, DBG_IMPORTANT, "WARNING: refresh_pattern maximum age negative. Cropped back to zero.");
+        i = 0;
+    }
+    if (i > 60*24*365) {
+        debugs(3, DBG_IMPORTANT, "WARNING: refresh_pattern maximum age too high. Cropped back to 1 year.");
+        i = 60*24*365;
+    }
+
     max = (time_t) (i * 60);   /* convert minutes to seconds */
 
     /* Options */