Skip to content

Return an error for an out-of-range non-encoded entry instead of panicking - #65

Open
gravenuance wants to merge 1 commit into
trumank:masterfrom
gravenuance:pr/non-encoded-entry-bounds
Open

gravenuance wants to merge 1 commit into
trumank:masterfrom
gravenuance:pr/non-encoded-entry-bounds

Conversation

@gravenuance

Copy link
Copy Markdown

A full directory index entry with a negative offset -n refers to non-encoded entry n - 1. That index was used unchecked, so a malformed or truncated pak panics with index out of bounds while the index is read, instead of returning an error. This returns a new Error::UnknownNonEncodedEntry(index, count) instead.

The added test writes a v11 pak, points its one directory-index offset at a non-encoded entry that doesn't exist, and expects the error. It panics without the change. cargo test --workspace passes apart from test_readme_help, which fails the same way on master on Windows.

…cking

A full directory index entry with a negative offset -n refers to non-encoded
entry n - 1. The index was used unchecked, so a malformed or truncated pak
panicked with "index out of bounds" while reading the index instead of
returning an error.
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