From: Amos Jeffries Date: Fri, 13 Aug 2010 09:37:46 +0000 (-0600) Subject: Fix 32-bit wrap in refresh_pattern min/max values. X-Git-Tag: take1~392 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a632ba718b926a6a3dc9b2c2a9576efe5be7bb07;p=thirdparty%2Fsquid.git Fix 32-bit wrap in refresh_pattern min/max values. 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. --- diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 673d3cc5a1..c8da2f0792 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -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 */