Skip to content

Commit 77d7234

Browse files
committed
Mutants: static assert the cache is not unreasonably big
1 parent 495162f commit 77d7234

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/blockdir.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ impl BlockDir {
9696

9797
/// Remember the existence of this many blocks, even if we don't have their content.
9898
const EXISTENCE_CACHE_SIZE: usize = (64 << 20) / BLAKE_HASH_SIZE_BYTES;
99+
const {
100+
// Protect against excessive memory usage introduced by mutants.
101+
assert!(EXISTENCE_CACHE_SIZE < 1_000_000_000, "Cache size too large");
102+
}
99103

100104
BlockDir {
101105
transport,

0 commit comments

Comments
 (0)