Fix panic on folders with zero data blocks#38
Open
ozzieba wants to merge 1 commit intomdsteele:masterfrom
Open
Fix panic on folders with zero data blocks#38ozzieba wants to merge 1 commit intomdsteele:masterfrom
ozzieba wants to merge 1 commit intomdsteele:masterfrom
Conversation
Add bounds checks in FolderReader::seek_to_uncompressed_offset to return io::Error(InvalidData) instead of panicking with index out of bounds when a malformed CAB file has a folder with zero data blocks. Fixes mdsteele#37 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Owner
|
Thanks, and sorry for the slow reply. The linter is complaining, but looks good otherwise. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #37 --
FolderReader::seek_to_uncompressed_offsetpanics with "index out of bounds" when a malformed CAB file has a folder withnum_data_blocks == 0but file entries that reference it with a non-zero uncompressed offset.Changes:
self.data_blocks[self.current_block_index]: ifdata_blocksis empty, returnio::Error(InvalidData)instead of panickingself.current_block_indexin the seek loop: if the index exceedsnum_data_blocks, returnio::Error(InvalidData)instead of potentially panicking on subsequent iterationsFiles changed:
src/folder.rs-- two bounds checks inseek_to_uncompressed_offsetsrc/cabinet.rs-- one new testAll existing tests continue to pass.