Jens-G opened a new pull request, #3860:
URL: https://github.com/apache/thrift/pull/3860

   JIRA: [THRIFT-6262](https://issues.apache.org/jira/browse/THRIFT-6262)
   Client: go
   
   `THeaderTransport.Flush` wrote the frame length as `uint32(payload.Len())` 
with no upper bound. `ReadFrame` refuses a frame larger than 
`THeaderMaxFrameSize` or the configured `MaxFrameSize`, but `Flush` sent such 
frames anyway. On a 64-bit build, a payload of 4 GiB or more went out with a 
truncated length.
   
   Changes in `lib/go/thrift/header_transport.go`:
   - `Flush` applies the limits `ReadFrame` applies on both paths:
     - the header path the ticket names;
     - the plain framed path used to answer a framed binary or compact client, 
which has the same conversion.
   
     It refuses a larger frame with a `TProtocolException` of type `SIZE_LIMIT` 
before writing any of it. `THeaderMaxFrameSize` is below `math.MaxUint32`, so 
no separate 32-bit check is needed.
   - The header length field is a 16-bit count of 4-byte words, and a header 
block of more than 262140 bytes wrapped it. `Flush` now refuses such a block 
the same way.
   
   ### Compatibility
   
   A client that sends frames larger than its own `MaxFrameSize` (default 
16384000 bytes) now gets an error from `Flush`. Before, it sent a frame that a 
peer with the same configuration would refuse. `lib/go/README.md` has a note on 
raising the limit.
   
   ### Tests
   
   Three tests in `header_transport_test.go`, each with an at-limit case and an 
over-limit case:
   - **Header frame:** at the limit it is written and read back. One byte over, 
`Flush` returns `SIZE_LIMIT` and writes 0 bytes.
   - **Plain framed answer, binary and compact:** the same checks, run after 
reading a framed request.
   - **Header block:** a block of exactly 65535 words is written and read back. 
One byte more is refused, and 0 bytes are written.
   
   Results:
   - Against the unmodified library, the three over-limit cases fail because 
`Flush` returns nil.
   - Removing each of the three new checks in turn fails the matching case, and 
so does turning `>` into `>=`.
   - `go vet -stdmethods=false` and `go test -race ./thrift` pass with Go 1.26 
and 1.27.
   - `GOARCH=386` vet and tests pass as well.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to