Skip to content

Fix packed stream count check in SevenZFile.sanityCheckUnpackInfo - #791

Merged
garydgregory merged 1 commit into
apache:masterfrom
kali834x:sevenz-packed-stream-count
Jul 31, 2026
Merged

Fix packed stream count check in SevenZFile.sanityCheckUnpackInfo#791
garydgregory merged 1 commit into
apache:masterfrom
kali834x:sevenz-packed-stream-count

Conversation

@kali834x

Copy link
Copy Markdown
Contributor

sanityCheckUnpackInfo compares packedStreamsRequiredByFolders with numberOfPackedStreams the wrong way round, so the case its own error message names, folders needing more packed streams than kPackInfo declares, is the one that gets through. calculateStreamMap then walks folderFirstPackStreamIndex past the end of packStreamOffsets, and the first entry of the second folder of an archive declaring a single packed stream makes getNextEntry throw ArrayIndexOutOfBoundsException out of reopenFolderInputStream instead of the declared IOException; buildDecoderStack indexes packSizes with the same value. requiring the two counts to be equal keeps every archive the old comparison accepted, since it already rejected the opposite direction. the fuzz input behind the build-excluded SevenZReadSubStreamsInfoTest declares no packed streams for its single folder, so it now stops here rather than in the substream allocation.

  • Read the contribution guidelines for this project.
  • Read the ASF Generative Tooling Guidance if you use Artificial Intelligence (AI).
  • I used AI to create any part of, or all of, this pull request. Which AI tool was used to create this pull request, and to what extent did it contribute?
  • Run a successful build using the default Maven goal with mvn; that's mvn on the command line by itself.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible, but it is a best practice.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body. Note that a maintainer may squash commits during the merge process.

folders consuming more packed streams than kPackInfo declares slipped past the comparison and overran packStreamOffsets in reopenFolderInputStream.
@garydgregory garydgregory changed the title fix packed stream count check in SevenZFile.sanityCheckUnpackInfo Fix packed stream count check in SevenZFile.sanityCheckUnpackInfo Jul 30, 2026
@garydgregory
garydgregory requested a review from Copilot July 30, 2026 12:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@garydgregory
garydgregory merged commit 81bbc1d into apache:master Jul 31, 2026
22 of 23 checks passed
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.

3 participants