Skip to content

Reject missing main header in ArjArchiveInputStream.readMainHeader - #793

Merged
garydgregory merged 1 commit into
apache:masterfrom
kali834x:arj-missing-main-header
Aug 4, 2026
Merged

Reject missing main header in ArjArchiveInputStream.readMainHeader#793
garydgregory merged 1 commit into
apache:masterfrom
kali834x:arj-missing-main-header

Conversation

@kali834x

@kali834x kali834x commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

readHeader returns null when the basic header size field is zero, which is the arj end-of-archive marker, and readLocalFileHeader tests for that before using the result. readMainHeader does not, so an archive whose first header is the terminator reaches new ByteArrayInputStream(null) and throws NullPointerException out of a constructor that declares IOException; it escapes ArchiveStreamFactory the same way, since matches only needs the two signature bytes for the format to be detected. the whole input is 60 ea 00 00. throwing ArchiveException there matches the rest of readHeader's malformed-header handling, and the self-extracting path already rejects those bytes that way through findMainHeader, so only the streaming path changes. readHeader has two callers and this was the one missing the check.

Before you push a pull request, review this list:

  • 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.

readHeader returns null for the zero-length basic header that marks the end of an arj archive. readLocalFileHeader already tests for it, but readMainHeader passed it straight to ByteArrayInputStream, so an archive starting with the terminator threw NullPointerException instead of ArchiveException.
@garydgregory garydgregory changed the title reject missing main header in ArjArchiveInputStream.readMainHeader Reject missing main header in ArjArchiveInputStream.readMainHeader Aug 3, 2026
@garydgregory
garydgregory merged commit c9f8c42 into apache:master Aug 4, 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.

2 participants