Skip to content

COMPRESS-738: Report a missing entry when SevenZFile is read before getNextEntry() - #849

Open
Marti2203 wants to merge 1 commit into
apache:masterfrom
Marti2203:sevenz-read-before-next-entry
Open

Marti2203 wants to merge 1 commit into
apache:masterfrom
Marti2203:sevenz-read-before-next-entry

Conversation

@Marti2203

Copy link
Copy Markdown

Fixes COMPRESS-738.

SevenZFile.read() before the first getNextEntry() threw ArrayIndexOutOfBoundsException: Index -1, because getCurrentStream() read archive.files[currentEntryIndex] before reaching its own "No current 7z entry (call getNextEntry() first)." check. This throws that ArchiveException when currentEntryIndex is negative.

SevenZFileTest.testReadBeforeGetNextEntry (an archive with entries and one without) fails without the change and passes with it; SevenZFileTest and mvn -B -DskipTests -DskipITs pass.

This issue was found by an LLM-Enhanced Static Analysis Engine and verified manually. The patch and this description were prepared with AI assistance (Claude Code) and reviewed by me; the commit carries an Assisted-By: trailer.

…etNextEntry()

getCurrentStream() indexed archive.files with currentEntryIndex before
its "No current 7z entry" check, so read() before the first
getNextEntry() threw ArrayIndexOutOfBoundsException. Throw the existing
ArchiveException when there is no current entry.

Assisted-By: Claude Code:claude-opus-5-5
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