Skip to content

Commit

Permalink
Merge branch 'revert-3f015297' into 'release/v4.4'
Browse files Browse the repository at this point in the history
Revert "Merge branch 'bugfix/nvs_read_out_of_bounds' into 'release/v4.4'"

See merge request espressif/esp-idf!27856
  • Loading branch information
igrr committed Dec 12, 2023
2 parents c452233 + 0ae5b6c commit a2b4ddc
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions components/nvs_flash/src/nvs_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t*>(data) + offset, item.varLength.dataSize, static_cast<uint8_t> (chunkStart) + chunkNum);
if (err != ESP_OK) {
return err;
Expand All @@ -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;
}

Expand Down

0 comments on commit a2b4ddc

Please sign in to comment.