Skip to content

Fix/trie ref long node key and empty is shared - #145

Open
imlvts wants to merge 2 commits into
Adam-Vandervorst:masterfrom
imlvts:fix/trie-ref-long-node-key-and-empty-is-shared
Open

imlvts wants to merge 2 commits into
Adam-Vandervorst:masterfrom
imlvts:fix/trie-ref-long-node-key-and-empty-is-shared

Conversation

@imlvts

@imlvts imlvts commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Fix TrieRef lookups with a node key longer than its buffer
new_with_key_and_path_in copied the focus's node key into a fixed stack
buffer, overflowing it (UB in release) when the key was longer, and
truncated key + path when the two together didn't fit. No child key is
longer than a node key, so only the first MAX_NODE_KEY_BYTES bytes of the
combined key can decide a step: look up that prefix, and keep stepping
through a child that begins within the node key. A combined key too long
to remain at a node is invalid.

(similar to Luke's 203b7d5))

Fix TrieRef::is_shared on an empty node

new_with_key_and_path_in copied the focus's node key into a fixed stack
buffer, overflowing it (UB in release) when the key was longer, and
truncated key + path when the two together didn't fit. No child key is
longer than a node key, so only the first MAX_NODE_KEY_BYTES bytes of the
combined key can decide a step: look up that prefix, and keep stepping
through a child that begins within the node key. A combined key too long
to remain at a node is invalid.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant