Skip to content

Commit

Permalink
snapshots: fix .bt key decoding (#2685)
Browse files Browse the repository at this point in the history
Problem:
The key span was spanning until the end of encoded data leading to OOM when trying to decode big .bt files.

Solution:
Limit it using decoded key_length.
  • Loading branch information
battlmonstr authored Jan 30, 2025
1 parent 9a04317 commit 43d4b52
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion silkworm/db/datastore/snapshots/btree/btree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ std::pair<BTree::Node, size_t> BTree::Node::from_encoded_data(std::span<uint8_t>
const auto key_length = endian::load_big_u16(encoded_key.data());
const auto encoded_size = kEncodedIndexPlusKeyLengthSize + key_length;
ensure(encoded_node.size() >= encoded_size, "snapshots::index::BTree invalid encoded node size");
const auto key = encoded_key.subspan(sizeof(uint16_t));
const auto key = encoded_key.subspan(sizeof(uint16_t), key_length);
return {Node{key_index, Bytes{key.data(), key.size()}}, encoded_size};
}

Expand Down

0 comments on commit 43d4b52

Please sign in to comment.