]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix 32-bit wrap in refresh_pattern min/max values.
authorAmos Jeffries <amosjeffries@squid-cache.org>
Fri, 13 Aug 2010 09:37:46 +0000 (03:37 -0600)
committerAmos Jeffries <amosjeffries@squid-cache.org>
Fri, 13 Aug 2010 09:37:46 +0000 (03:37 -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 673d3cc5a1faacc2e6e88a35679126b2a7aac8b6..c8da2f07929085e9b3bec65c36627b5a585ff071 100644 (file)
@@ -2478,6 +2478,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 */
@@ -2486,6 +2496,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 */