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.
This commit is contained in:
Sam Caulfield
2020-08-04 11:14:10 +01:00
parent 8172b40813
commit 44e9260a3e
+1 -1
View File
@@ -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;