From 44e9260a3e3e313f1ae1b6e857ea1f9c4416dbd0 Mon Sep 17 00:00:00 2001 From: Sam Caulfield Date: Tue, 4 Aug 2020 11:10:04 +0100 Subject: [PATCH] Fix possible source of overflow in SPIFFS_check pages_per_scan can overflow in some file system configurations. This could occur for example in a file system where the logical page size is 32 KiB and the type of spiffs_page_ix is uint16_t. --- src/spiffs_check.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spiffs_check.c b/src/spiffs_check.c index 0331fb1..8c7812b 100644 --- a/src/spiffs_check.c +++ b/src/spiffs_check.c @@ -521,7 +521,7 @@ s32_t spiffs_lookup_consistency_check(spiffs *fs, u8_t check_all_objects) { // The working memory might not fit all pages so several scans might be needed static s32_t spiffs_page_consistency_check_i(spiffs *fs) { const u32_t bits = 4; - const spiffs_page_ix pages_per_scan = SPIFFS_CFG_LOG_PAGE_SZ(fs) * 8 / bits; + const u32_t pages_per_scan = SPIFFS_CFG_LOG_PAGE_SZ(fs) * 8 / bits; s32_t res = SPIFFS_OK; spiffs_page_ix pix_offset = 0;