From e74be525361e6ec07a67aff39e5ca029bf7d46d8 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Tue, 17 Aug 2010 19:46:52 -0600 Subject: [PATCH] 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. --- src/cache_cf.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 280308d1b9..3a7a2a4429 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -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 */ -- 2.47.3