Repository navigation
Auto-port 5.0: Check the second gzip magic byte in JdkZlibDecoder - #18006
Merged
Merged
Conversation
Motivation: `JdkZlibDecoder` reads both gzip magic bytes (ID1 = 0x1f, ID2 = 0x8b, RFC 1952 section 2.3.1) but only checks ID1, so a stream with a wrong ID2 is decoded as gzip. `java.util.zip.GZIPInputStream` and netty's own `JdkZlibDecompressor` (`magic0 != 31 || magic1 != 139`) reject such a stream. Modification: - Read both bytes unsigned and check ID2, as `JdkZlibDecompressor` does. - Add `JdkZlibTest.testGzipInvalidSecondMagicByteThrows`. Result: `JdkZlibDecoder` rejects input whose gzip header has a wrong ID2. Co-authored-by: Norman Maurer <[email protected]> (cherry picked from commit f69f14a)
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.
Auto-port of #17972 to 5.0
Cherry-picked commit: f69f14a
Motivation:
JdkZlibDecoderreads both gzip magic bytes (ID1 = 0x1f, ID2 = 0x8b, RFC 1952 section 2.3.1) but only checks ID1, so a stream with a wrong ID2 is decoded as gzip.java.util.zip.GZIPInputStreamand netty's ownJdkZlibDecompressor(magic0 != 31 || magic1 != 139) reject such a stream.Modification:
JdkZlibDecompressordoes.JdkZlibTest.testGzipInvalidSecondMagicByteThrows.Result:
JdkZlibDecoderrejects input whose gzip header has a wrong ID2.Reproduction on 4.2 (5776ebc): compress
"hello gzip"withGZIPOutputStreamand set byte 1 to0x00:With this change
JdkZlibDecoderthrowsDecompressionException: Input is not in the GZIP format. The new test fails without the change (no exception is thrown). The*Zlib*Testtests incodec-compressionpass.This issue was found by an LLM-Enhanced Static Analysis Engine and verified manually.
🤖 Generated with Claude Code