Skip to content

Don't panic - #42

Open
losynix wants to merge 6 commits into
ColinFinck:masterfrom
losynix:dont-panic
Open

losynix wants to merge 6 commits into
ColinFinck:masterfrom
losynix:dont-panic

Conversation

@losynix

@losynix losynix commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Hello Colin,

Here are various checks & fixes to avoid panics, endless loops or unbounded memory consumption (explanation in commits & comments).

Those issues where found fuzzing the crate.

The MAX_INDEX_DEPTH of 64 and MAX_INDEX_RECORD_SIZE of 64KB are very conservative values, they could be lower and can be changed if you prefer.

Thank you

Avoid panic with out of bounds indexing if entry length is smaller than
INDEX_ENTRY_HEADER_SIZE

Also confine `IndexNodeEntryRanges` to the used range of the index node
instead of the remainder of the entire buffer
An `entries_offset` beyond `index_size` produced a slice range with
start > end and panicked

Also use saturating add when computing range to stay safe on 32-bit targets
Check for sane min/max values of Index Record size; a smaller size than the
records headers would cause an out of bounds panic, a large size would
cause huge allocations
Add more checks / use verified arithmetic when computing record sizes to
avoid overflows
This reasonable limit avoid endless loops and unbounded memory usage
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