Repository navigation
Fix COMPRESS-709: GzipCompressorInputStream fails on trailing zero padding after the last member - #835
Open
Inf1mum wants to merge 1 commit into
Open
Fix COMPRESS-709: GzipCompressorInputStream fails on trailing zero padding after the last member#835Inf1mum wants to merge 1 commit into
Inf1mum wants to merge 1 commit into
Conversation
…mber Signed-off-by: Inf1mum <vadim.lazuk@mail.ru>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes COMPRESS-709.
Problem
A valid .gz stream followed by trailing zero bytes makes
GzipCompressorInputStreamin 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 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:
"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 is0x00, 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 testover 37 compressor test classes - 273/273 green (1 pre-existing skip);mvn checkstyle:checkpasses.