Repository navigation
fix byte count returned by httpPeek for content-encoded data - #175
Closed
tanjiroK-coder wants to merge 1 commit into
Closed
tanjiroK-coder wants to merge 1 commit into
tanjiroK-coder wants to merge 1 commit into
Conversation
Member
|
So you missed the debug printf above this, but I'll go ahead and make the change here and in CUPS 2.x. |
michaelrsweet
added a commit
that referenced
this pull request
Oct 7, 2026
Member
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.
httpPeekdecompresses into the caller's buffer through a copy of the inflate stream, made withinflateCopyso that a peek doesn't consume the pending input, but the byte count it returns is still read offhttp->streamrather than the copy thatinflateactually wrote through. The original'savail_outis never set for the gunzip/inflate direction, sincehttp_content_coding_startcallocs thez_streamandinflateInit2leaves that field alone, and otherwise holds a stale leftover from the previoushttpRead, so the count comes back as the clampedlengthinstead of the number of bytes produced. On aContent-Encoding: gzipresponse that means the caller is told it peeked the compressed length and treats the tail of its own buffer as body data. I noticed it reading the two gunzip paths side by side:httpReadsetsavail_outon the stream it inflates with and reads it back off the same one, whilehttpPeeksets it onstreamand reads it offhttp->stream. Against a 13-byte body served as 33 bytes of gzip,httpPeekreturned 33 with the trailing 20 bytes of the buffer untouched; it returns 13 with this change, and deflate behaves the same way.ippeveprinterhappens to zero its auto-type header first so it only gets a wrong count back, but a caller that doesn't is reading uninitialised memory.Assisted-by: Claude:claude-opus-5 [Claude Code]