You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
file_store: oversized entry length prefix panics Store::load instead of returning an error #2306
EntryIter::next decodes each entry with bincode_options().deserialize_from(..), and bincode_options() (crates/file_store/src/lib.rs) sets no size limit. A length prefix read from the file is therefore passed straight to the buffer allocation. An entry declaring a String length of u64::MAX panics with capacity overflow inside Store::load; smaller but still oversized lengths attempt a huge allocation instead of returning StoreError::Bincode.
This affects loading a corrupted or hand-edited store file. #2258 appears to address this by bounding the frame allocation.
This issue was found by AI.
To Reproduce
Add crates/file_store/tests/test_oversized_len.rs and run cargo test -p bdk_file_store --test test_oversized_len:
use bdk_file_store::Store;use std::collections::BTreeSet;constMAGIC:&[u8] = b"bdk_test_magic";#[test]fnload_returns_error_on_oversized_length_prefix(){let dir = tempfile::tempdir().unwrap();let path = dir.path().join("db");letmut bytes = MAGIC.to_vec();
bytes.push(1);// BTreeSet length: 1 element
bytes.push(253);// bincode varint tag: u64 follows
bytes.extend_from_slice(&u64::MAX.to_le_bytes());// String length: u64::MAX
std::fs::write(&path,&bytes).unwrap();let result = Store::<BTreeSet<String>>::load(MAGIC,&path);assert!(result.is_err(),"load should fail with an error, not panic");}
Current output:
thread 'load_returns_error_on_oversized_length_prefix' panicked at library/alloc/src/raw_vec/mod.rs:28:5:
capacity overflow
Expected behavior
Loading a store file whose entry declares a length that cannot be satisfied should return an error rather than panic or attempt an unbounded allocation.
Activity
Brijesh-Thakkar commentedon Sep 30, 2026
I would love to work on this issue
will raise PR for this one
Brijesh-Thakkar commentedon Sep 30, 2026
I'm not opening a separate fix. #2258 already handles this, and I've left the verification details in a comment there.
luhrhenz commentedon Oct 8, 2026
created a pr to fix this issue..