Apple MMKVCore allKeys() truncates keys at embedded NUL bytes
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 86/100
Research direction
In Core/MMKV_OSX.cpp lines 477–485, allKeys() builds a string from NSString.UTF8String without a byte count. Read that implementation and check how the Objective-C wrapper enumerates the same key. Preserve the full UTF-8 byte length, then verify that a key containing an embedded NUL is returned intact.
Written by the indexing model from the issue text.
Description
On iOS with MMKVCore 2.4.2, a key containing an embedded NUL can be stored and looked up, but the C++ allKeys() result loses the bytes after the NUL.
In an Objective-C++ iOS app, initialize MMKV with an empty app-local directory and run:
auto* store = mmkv::MMKV::mmkvWithID("nul-key-repro");
const std::string_view key("key\0tail", 8);
const bool saved = store->set(true, key);
const bool found = store->containsKey(key);
const auto keys = store->allKeys();
Both saved and found are true. The returned key is "key", where I expected the original eight bytes. I reproduced the same result when reopening a store written through the Objective-C wrapper, which enumerates the complete key.
In Core/MMKV_OSX.cpp, allKeys() constructs a string from NSString.UTF8String without supplying a byte count. Using the UTF-8 byte length preserves the embedded NUL. Implementation
- Dominant language
- C++
- Stars
- 18.8k
- Forks
- 2k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 8
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Tencent/MMKV
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
ROCm/rocm-libraries#15665 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
qbittorrent/qBittorrent#25265 · 1 comment ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
shadps4-emu/shadPS4#5705 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
shadps4-emu/shadps4-qtlauncher#516 ·
Maintainers usually reply within 2 days