Inf1mum opened a new pull request, #835: URL: https://github.com/apache/commons-compress/pull/835
Fixes [COMPRESS-709](https://issues.apache.org/jira/browse/COMPRESS-709). ## Problem A valid .gz stream followed by trailing zero bytes makes `GzipCompressorInputStream` in concatenated mode fail with `"Unexpected data after a valid .gz stream."` (reported as `"Garbage after a valid .gz stream."` in 1.26.x). GNU gzip decompresses the same input silently with exit code 0: trailing NUL padding after the last member is a common artifact of block-aligned storage and tape/file copies. The [file attached to the ticket](https://issues.apache.org/jira/secure/attachment/13078448/tinyxml.tar.gz) is a valid single-member gzip stream (CRC32 and ISIZE verified) whose 10,020 trailing zero bytes are pure padding - GNU gzip accepts it, commons-compress rejects it. For reference, GNU gzip behavior: - trailing all-zero bytes after the last member: accepted silently, exit 0; - trailing non-zero garbage: `"decompression OK, trailing garbage ignored"`, exit 2. ## Change When looking for the next member in concatenated mode (`init(false)`), if the byte after the member is `0x00`, the remaining input is consumed: if it is all zeros, the stream ends cleanly; if any non-zero byte is found, the previous exception is thrown as before. Detection of the first member and non-concatenated mode are unchanged. The class Javadoc now documents the tolerated padding. ## Tests - `testCompress709TrailingZeroPaddingIsIgnored` - a member followed by 16 KiB of zero padding decompresses cleanly in both concatenated and non-concatenated modes; it fails on unpatched master with exactly the reported exception. - `testCompress709TrailingGarbageIsStillRejected` - non-zero trailing garbage still throws `"Unexpected data after a valid .gz stream."`. Verified end-to-end against the file attached to COMPRESS-709: decompresses to the same 204,288 bytes GNU gzip produces. In Docker `maven:3.9-eclipse-temurin-21`: `mvn test` over 37 compressor test classes - 273/273 green (1 pre-existing skip); `mvn checkstyle:check` passes. -- 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]
