From 0ae5b6c0b2dbc626fe3dda34d29d8afce4ce7165 Mon Sep 17 00:00:00 2001 From: Martin Vychodil Date: Tue, 12 Dec 2023 13:30:50 +0800 Subject: [PATCH] Revert "Merge branch 'bugfix/nvs_read_out_of_bounds' into 'release/v4.4'" This reverts merge request !27852 --- components/nvs_flash/src/nvs_storage.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/components/nvs_flash/src/nvs_storage.cpp b/components/nvs_flash/src/nvs_storage.cpp index 89f0eb3a7a..cd1cb14edc 100644 --- a/components/nvs_flash/src/nvs_storage.cpp +++ b/components/nvs_flash/src/nvs_storage.cpp @@ -478,11 +478,6 @@ esp_err_t Storage::readMultiPageBlob(uint8_t nsIndex, const char* key, void* dat } return err; } - if (item.varLength.dataSize > dataSize - offset) { - /* The size of the entry in the index is inconsistent with the sum of the sizes of chunks */ - err = ESP_ERR_NVS_INVALID_LENGTH; - break; - } err = findPage->readItem(nsIndex, ItemType::BLOB_DATA, key, static_cast(data) + offset, item.varLength.dataSize, static_cast (chunkStart) + chunkNum); if (err != ESP_OK) { return err; @@ -491,14 +486,11 @@ esp_err_t Storage::readMultiPageBlob(uint8_t nsIndex, const char* key, void* dat offset += item.varLength.dataSize; } - - if (err == ESP_ERR_NVS_NOT_FOUND || err == ESP_ERR_NVS_INVALID_LENGTH) { - // cleanup if a chunk is not found or the size is inconsistent - eraseMultiPageBlob(nsIndex, key); - } - NVS_ASSERT_OR_RETURN(offset == dataSize, ESP_FAIL); + if (err == ESP_ERR_NVS_NOT_FOUND) { + eraseMultiPageBlob(nsIndex, key); // cleanup if a chunk is not found + } return err; }