GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Fix JdkZlibDecompressor losing the tail of highly compressible streams by renechoi · Pull Request #17191 · netty/netty Fix JdkZlibDecompressor losing the tail of highly compressible streams #17191New issueHave a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community. By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails. Already on GitHub? Sign in to your account
Merged
normanmaurer
merged 2 commits into
netty:4.2
from
renechoi:fix/jdkzlib-decompressor-tail-loss
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from 1 commit
Commits
File filterConversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page. Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page. Diff viewDiff view
Next
Fix JdkZlibDecompressor losing the tail of highly compressible streams
### Motivation `JdkZlibDecompressor#processOutput` sizes every output buffer as `inflater.getRemaining() << 1`. The number of remaining input bytes is only a hint: the inflater may still hold decoded data that did not fit into the previous output buffer, and by then it may have pulled the last input bytes into its internal state, so `getRemaining()` is `0` and the proposed buffer has zero capacity. `inflate(...)` cannot make progress with it, and because `status()` maps `inflater.needsInput()` straight to `NEED_INPUT`, the caller is asked for more input instead of draining the pending output. At the end of the stream `endOfInput()` then fails with `Compressed stream ended before the end-of-stream marker`, even though the stream was complete and valid. Measured with 100000 bytes of `'a'` deflated raw (115 bytes, ratio ~870:1): only 99848 bytes are produced, the remaining 152 bytes stay inside the `Inflater`, and the call throws. The legacy `JdkZlibDecoder` decodes the same bytes to all 100000, because it inflates into one buffer that it keeps expanding, so `inflate(...)` always has room. `ZlibWrapper.ZLIB` and `ZlibWrapper.GZIP` hide the problem, as their trailer keeps `getRemaining()` above zero until the inflater is finished. ### Modification - Never propose a zero-sized output buffer: `processOutput` floors the proposed capacity at `MIN_OUTPUT_BUFFER_SIZE` (512 bytes). `maxAllocation` still caps it exactly as before. - Remember whether the last `inflate(...)` filled the output buffer completely and, if it did, report `NEED_OUTPUT` from `status()`, so pending output is drained before more input is requested. `needsInput()` only says that all input bytes were consumed, not that all output was produced. ### Result A valid deflate stream is fully decompressed regardless of its compression ratio.
Uh oh!
There was an error while loading. Please reload this page.
commit 7dbaebba7c4e5c8d274b718896828a700af98afa
There are no files selected for viewing
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
|
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |