Conversation
…d frame size Client: go TFramedTransport.Flush checked a frame against math.MaxUint32 only, so it wrote frames larger than the transport's MaxFrameSize, which readFrame refuses. Flush now applies the configured maximum and returns a TTransportException before writing any part of a larger frame. The maximum is below what the 32-bit length can carry, so the old check is covered by it. The refused frame is dropped with the write buffer, so the transport stays usable for the next one. lib/go/README.md notes the change for clients that send frames larger than the default. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
fishy
reviewed
Sep 16, 2026
| // readFrame refuses a frame larger than the configured maximum, and so does | ||
| // a peer holding the same configuration. The maximum is below what the | ||
| // 32-bit length can carry. A refused frame is dropped with the buffer. | ||
| if maxSize := p.cfg.GetMaxFrameSize(); int64(size) > int64(maxSize) { |
Member
There was a problem hiding this comment.
should we reuse the same helper in THeader implementation? in that helper we also checked against MaxUint32 which we didn't do here.
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.
JIRA: THRIFT-6281
Client: go
TFramedTransport.Flushchecked a frame againstmath.MaxUint32only.readFramerefuses a frame larger than the configuredMaxFrameSize(default 16384000), butFlushwrote such frames. Measured on master withMaxFrameSize: 1024:Flushof a 2048-byte frame returned nil and wrote 2052 bytes, and aTFramedTransportwith the same configuration refused that frame with "Incorrect frame size (2048)".This is the plain framed counterpart of #3860 (THRIFT-6262), which does the same for
THeaderTransport.Change
FlushappliesGetMaxFrameSize(). A larger frame is refused with aTTransportException, like the existing checks in this file, and nothing of it is written.GetMaxFrameSize()never exceedsmath.MaxInt32, so the new check also covers the oldMaxUint32one.deferthat returns the write buffer now runs before the check, so a refused frame is dropped. The nextWrite/Flushstarts from an empty buffer rather than failing again on the same oversized one.lib/go/README.mdgets a note for clients that send frames larger than the default. The note sits before the TLS section, so it does not collide with the one THRIFT-6262: Hold the frames THeaderTransport writes to the configured frame size #3860 appends.Compatibility
A client that writes frames larger than its own
MaxFrameSizenow gets an error fromFlushinstead of sending a frame that a peer with the same configuration refuses.Tests
New
TestTFramedTransportFlushFrameSizeLimit:Flushreturns aTTransportExceptionand writes 0 bytes. The next small frame then goes out on its own, 4 + 4 bytes.Results:
Flushreturned nil.>→>=;go vet -stdmethods=falseandgo test -race ./thriftpass with Go 1.26 and 1.27, andGOARCH=386vet and tests pass as well.🤖 Generated with Claude Code