Merge branch 'fix/nvs_tool_entry_unknown_type_crash' into 'master'

fix(nvs): Fix nvs_tool accepting an unknown entry type

See merge request espressif/esp-idf!30503
pull/13856/head
Adam Múdry 2024-05-17 21:05:22 +08:00
commit 7b32f27e81
3 zmienionych plików z 19 dodań i 13 usunięć

Wyświetl plik

@ -1,7 +1,10 @@
#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
from typing import Any, Dict, List, Optional
from typing import Any
from typing import Dict
from typing import List
from typing import Optional
from zlib import crc32
@ -123,9 +126,9 @@ class NVS_Page:
# Load an entry
entry = NVS_Entry(
i - 2,
page_data[i * nvs_const.entry_size: (i + 1) * nvs_const.entry_size],
entry_states[i - 2],
index=(i - 2),
entry_data=page_data[i * nvs_const.entry_size: (i + 1) * nvs_const.entry_size],
entry_state=entry_states[i - 2],
)
self.entries.append(entry)
@ -137,13 +140,13 @@ class NVS_Page:
if page_addr * nvs_const.entry_size >= nvs_const.page_size:
break
child_entry = NVS_Entry(
entry_idx,
page_data[
index=entry_idx,
entry_data=page_data[
page_addr
* nvs_const.entry_size: (page_addr + 1)
* nvs_const.entry_size
],
entry_states[entry_idx],
entry_state=entry_states[entry_idx],
)
entry.child_assign(child_entry)
entry.compute_crc()
@ -269,7 +272,9 @@ class NVS_Entry:
for entry in self.children:
children_data += entry.raw
if self.data:
children_data = children_data[: self.data['size']] # Discard padding
if self.data['value'] is not None:
if self.data['size']:
children_data = children_data[: self.data['size']] # Discard padding
self.metadata['crc']['data_computed'] = crc32(children_data, 0xFFFFFFFF)
def toJSON(self) -> Dict[str, Any]:
@ -279,7 +284,7 @@ class NVS_Entry:
is_empty=self.is_empty,
index=self.index,
metadata=self.metadata,
children=self.children,
key=self.key,
data=self.data,
children=self.children,
)

Wyświetl plik

@ -1,5 +1,5 @@
#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
import argparse
import os
@ -25,11 +25,11 @@ def program_args() -> argparse.Namespace:
help='check partition for potential errors',
)
tmp = {
'all': 'print everything',
'all': 'print written, erased and empty entries',
'written': 'print only currently written entries',
'minimal': 'print only namespace:key=value pairs',
'namespaces': 'list all written namespaces',
'blobs': 'print all blobs and strings',
'namespaces': 'list all written namespaces',
'storage_info': 'print storage related information (free/used entries, etc)',
'none': 'do not print anything (if you only want to do integrity check)',
}

Wyświetl plik

@ -14,6 +14,7 @@ components/heap/test_multi_heap_host/test_all_configs.sh
components/mbedtls/esp_crt_bundle/gen_crt_bundle.py
components/mbedtls/esp_crt_bundle/test_gen_crt_bundle/test_gen_crt_bundle.py
components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py
components/nvs_flash/nvs_partition_tool/nvs_tool.py
components/partition_table/check_sizes.py
components/partition_table/gen_empty_partition.py
components/partition_table/gen_esp32part.py