From: Alex Rousskov Date: Mon, 30 Jan 2012 17:57:54 +0000 (-0700) Subject: Use -2 instead of -1 as the minimum sane time in swap.state entries X-Git-Tag: BumpSslServerFirst.take05~12^2~65 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=68992b63c4b19f493a06c6e6136ca5c4512ec087;p=thirdparty%2Fsquid.git Use -2 instead of -1 as the minimum sane time in swap.state entries because StoreSwapLogData::expires documentation says it sometimes uses -2. --- diff --git a/src/StoreSwapLogData.cc b/src/StoreSwapLogData.cc index 47b7468605..e8856601f6 100644 --- a/src/StoreSwapLogData.cc +++ b/src/StoreSwapLogData.cc @@ -47,13 +47,15 @@ StoreSwapLogData::sane() const // TODO: These checks are rather weak. A corrupted swap.state may still // cause havoc (e.g., cur_size may become astronomical). Add checksums? + const time_t minTime = -2; // -1 is common; expires sometimes uses -2 + // Check what we safely can; for some fields any value might be valid return SWAP_LOG_NOP < op && op < SWAP_LOG_MAX && swap_filen >= 0 && - timestamp >= -1 && // in case some code is using -1 to mean "n/a" - lastref >= -1 && - expires >= -1 && - lastmod >= -1 && + timestamp >= minTime && + lastref >= minTime && + expires >= minTime && + lastmod >= minTime && swap_file_sz > 0; // because swap headers ought to consume space }