Unverified Commit 4872a879 authored by vercel-fleet-prod[bot]'s avatar vercel-fleet-prod[bot] Committed by GitHub

turbo-persistence: validate SST layout before opening

Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
parent bb63c720
...@@ -30,7 +30,7 @@ use turbo_persistence::{ ...@@ -30,7 +30,7 @@ use turbo_persistence::{
KEY_BLOCK_ENTRY_TYPE_INLINE_MIN, KEY_BLOCK_ENTRY_TYPE_KEY_DELETED, KEY_BLOCK_ENTRY_TYPE_INLINE_MIN, KEY_BLOCK_ENTRY_TYPE_KEY_DELETED,
KEY_BLOCK_ENTRY_TYPE_KEY_VALUE_DELETED_MIN, KEY_BLOCK_ENTRY_TYPE_MEDIUM, KEY_BLOCK_ENTRY_TYPE_KEY_VALUE_DELETED_MIN, KEY_BLOCK_ENTRY_TYPE_MEDIUM,
KEY_BLOCK_ENTRY_TYPE_SMALL, KEY_BLOCK_TABLE_ENTRY_SIZE_NO_HASH, KeyBlockLayout, KEY_BLOCK_ENTRY_TYPE_SMALL, KEY_BLOCK_TABLE_ENTRY_SIZE_NO_HASH, KeyBlockLayout,
key_block_table_stride, StaticSortedFileMetaData, key_block_table_stride,
}, },
}; };
...@@ -498,7 +498,11 @@ fn analyze_sst_file(db_path: &Path, info: &SstInfo) -> Result<SstStats> { ...@@ -498,7 +498,11 @@ fn analyze_sst_file(db_path: &Path, info: &SstInfo) -> Result<SstStats> {
..Default::default() ..Default::default()
}; };
let block_offsets_start = mmap.len() - (info.block_count as usize * size_of::<u32>()); let block_offsets_start = StaticSortedFileMetaData {
sequence_number: info.sequence_number,
block_count: info.block_count,
}
.checked_block_offsets_start(mmap.len())?;
// Read the index block (always the last block) first to learn which blocks are key blocks. // Read the index block (always the last block) first to learn which blocks are key blocks.
// Without this, we'd have to guess block types from their first byte, which is wrong for // Without this, we'd have to guess block types from their first byte, which is wrong for
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment