Just got reminded about the 32-bit wrap problem in refresh_pattern min/max values.

Attached patch limits the values to 1 year (arbitrary based on rumours). Checking for 32-bit wrap and setting the max 1 year limit instead of cutting them to zero.

The expected outcome of this is actual caching by refresh_pattern when people desperately set in/max to > a million minutes. Instead of a silent always-stale verdict.

Amos
--
Please be using
  Current Stable Squid 2.7.STABLE9 or 3.1.5
=== modified file 'src/cache_cf.cc'
--- src/cache_cf.cc	2010-07-07 16:41:03 +0000
+++ src/cache_cf.cc	2010-07-15 07:40:11 +0000
@@ -622,6 +622,10 @@
     if (Config.errHtmlText == NULL)
         Config.errHtmlText = xstrdup(null_string);
 
+    if (Config.local_file_dir != NULL) {
+        requirePathnameExists("local_file_dir", Config.local_file_dir);
+    }
+
     storeConfigure();
 
     snprintf(ThisCache, sizeof(ThisCache), "%s (%s)",
@@ -2476,17 +2480,26 @@
     pattern = xstrdup(token);
 
     i = GetInteger();		/* token: min */
-
     min = (time_t) (i * 60);	/* convert minutes to seconds */
 
+    /* catch insanely huge values close to 32-bit wrap */
+    if (min < i || min > 60*60*24*365) {
+        debugs(3, DBG_IMPORTANT, "WARNING: refresh_pattern minimum age too high. Cropped back to 1 year.");
+        min = 60*60*24*365;
+    }
+
     i = GetInteger();		/* token: pct */
-
     pct = (double) i / 100.0;
 
     i = GetInteger();		/* token: max */
-
     max = (time_t) (i * 60);	/* convert minutes to seconds */
 
+    /* catch insanely huge values close to 32-bit wrap */
+    if (max < i || max > 60*60*24*365) {
+        debugs(3, DBG_IMPORTANT, "WARNING: refresh_pattern maximum age too high. Cropped back to 1 year.");
+        max = 60*60*24*365;
+    }
+
     /* Options */
     while ((token = strtok(NULL, w_space)) != NULL) {
         if (!strcmp(token, "refresh-ims")) {

Reply via email to