]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Use -2 instead of -1 as the minimum sane time in swap.state entries
authorAlex Rousskov <rousskov@measurement-factory.com>
Mon, 30 Jan 2012 17:57:54 +0000 (10:57 -0700)
committerAlex Rousskov <rousskov@measurement-factory.com>
Mon, 30 Jan 2012 17:57:54 +0000 (10:57 -0700)
because StoreSwapLogData::expires documentation says it sometimes uses -2.

src/StoreSwapLogData.cc

index 47b7468605114660248d04de9163709dfec02bad..e8856601f60bf546c36aeda8c7b0a240d6928cec 100644 (file)
@@ -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
 }