fix off-by-ten header bounds check in readHeaderFormat#3597
Open
dxbjavid wants to merge 2 commits into
Open
Conversation
THeaderTransport.cpp is compiled into libthriftz, not libthrift. Without this link, the new THeaderTransport test case produces an undefined reference to the vtable at link time. Client: cpp Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
readHeaderFormat checks the declared header size against the whole frame size, but the parse pointer has already moved past the 10-byte common header before that check, so a header size landing in the last 10 bytes of the frame leaves the header boundary pointing up to 10 bytes beyond the receive buffer. The varint and string readers only stop at that boundary, so a malformed THeader frame makes them read past the end of the buffer. Comparing the header section against the remaining sz - 10 bytes keeps the boundary inside the allocation, and the added test drives the read path with such a frame.
[skip ci]anywhere in the commit message to free up build resources.