aaronjmars opened a new pull request, #853:
URL: https://github.com/apache/commons-compress/pull/853
Two places where `TarArchiveInputStream` bounds an entry by the wrong size,
so reading one entry can lose its data or run into the next header. `TarFile`
handles both cases already.
**PAX `size` override.** `getNextEntry()` builds `currentInputStream` with
the ustar header size, then applies the PAX headers. When a PAX `size` record
overrides the header value, the stream keeps the old bound. With header size 0
and PAX `size=1`, the entry reports size 1 but reads as empty, and its data
record is later parsed as the next header, so the following entry is lost (GNU
tar extracts both). The stream is now rebuilt from the PAX-adjusted size when
it differs.
**PAX GNU 1.0 sparse map.** For 1.0 sparse entries the sparse map sits at
the start of the entry body and is read through `currentInputStream`, but
`buildSparseInputStreams()` then checks the extents against the full stored
size, which still includes the map. An entry whose body is only the map, with
one 512 byte extent, returns 512 bytes taken from the next entry's header. The
consumed map bytes (with padding) are now subtracted from the entry size before
the extents are checked, as `TarFile` does, so such an entry is rejected by the
check added in #780.
Tests:
- `TarArchiveInputStreamTest.testPaxSizeOverridesHeaderSize`
-
`SparseFilesTest.testPax1xSparseMapCountsAgainstEntrySizeTarArchiveInputStream`
(valid map plus data still reads, next entry intact)
-
`SparseFilesTest.testRejectsPax1xSparseBlocksLargerThanDataAfterMap{TarArchiveInputStream,TarFile}`
The archive helpers in `SparseFilesTest` are now package-private so the PAX
size test can reuse them. I don't have a JIRA account, so there is no ticket id
yet.
- [x] Read the [contribution guidelines](CONTRIBUTING.md) for this project.
- [x] Read the [ASF Generative Tooling
Guidance](https://www.apache.org/legal/generative-tooling.html) if you use
Artificial Intelligence (AI).
- [x] I used AI to create any part of, or all of, this pull request. AI
tooling helped find the issue and draft the change and tests; I reviewed them.
- [ ] Run a successful build using the default
[Maven](https://maven.apache.org/) goal with `mvn`; I could not run Maven
locally, relying on CI here.
- [x] Write unit tests that match behavioral changes, where the tests fail
if the changes to the runtime are not applied.
- [x] Write a pull request description that is detailed enough to understand
what the pull request does, how, and why.
- [x] Each commit in the pull request should have a meaningful subject line
and body.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]