Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix chip-tool PersistentStorageDelegate failing on some keys (#20239)
* Fix chip-tool PersistentStorageDelegate failing on some keys - chip-tool's PersistentStorageDelegate failed the audit: ``` [1656721506.201383][688277:688277] CHIP:ATM: ../../../examples/chip-tool/third_party/connectedhomeip/src/lib/support/PersistentStorageAudit.cpp:248: assertion failed: "err == CHIP_NO_ERROR" [1656721506.201409][688277:688277] CHIP:ATM: ../../../examples/chip-tool/third_party/connectedhomeip/src/lib/support/PersistentStorageAudit.cpp:249: assertion failed: "size == strlen(kBase64SymbolValues)" [1656721506.201413][688277:688277] CHIP:ATM: ../../../examples/chip-tool/third_party/connectedhomeip/src/lib/support/PersistentStorageAudit.cpp:250: assertion failed: "0 == memcmp(&buf[0], kBase64SymbolValues, strlen(kBase64SymbolValues))" [1656721506.201437][688277:688277] CHIP:ATM: ../../../examples/chip-tool/third_party/connectedhomeip/src/lib/support/PersistentStorageAudit.cpp:255: assertion failed: "err == CHIP_NO_ERROR" ``` - The audit also crashed on SyncSetKeyValue with nullptr argument - To fail the audit, had to run the audit on a version that forcibly loaded what was stored again. - Root cause was base64 padding has `=` which confuses INI parser into giving out keys that are too small Issue #20188 This PR: - Implements `SyncDoesKeyExist` natively - Fixes handling of `nullptr` arguments and zero-size keys in the storage impl - Uses `\x00` C-style hex escaping for any characters that could fool the INI parser, which retains human readability of keys in the INI files, but fixes the bugs found by the audit - Removes unnecessary newliens in storage audit logging Testing done: - Unit tests still pass - Cert tests still pass - Storage audit passed ``` [1656722163.492413][696066:696066] CHIP:ATM: ==== PersistentStorageDelegate API audit: SUCCESS ==== ``` * Restyled by clang-format * Remove a stale temporary added during testing Co-authored-by: Restyled.io <[email protected]>
- Loading branch information