From 68992b63c4b19f493a06c6e6136ca5c4512ec087 Mon Sep 17 00:00:00 2001 From: Alex Rousskov Date: Mon, 30 Jan 2012 10:57:54 -0700 Subject: [PATCH] Use -2 instead of -1 as the minimum sane time in swap.state entries because StoreSwapLogData::expires documentation says it sometimes uses -2. --- src/StoreSwapLogData.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 } -- 2.47.3