kpumuk opened a new pull request, #3522: URL: https://github.com/apache/thrift/pull/3522
<!-- Explain the changes in the pull request below: --> Ruby was not consistently rejecting negative sizes while reading Thrift payloads. Size values appear in binary/string fields and in map/list/set headers. Those values must be non-negative. Before this change, malformed input could declare a negative size and reach Ruby or native C code paths that assumed the size was valid. This was a protocol hardening gap compared with other runtimes. ## Solution This change rejects negative sizes in the Ruby library read paths. It adds validation for: - binary protocol map/list/set headers - binary/string payload sizes - JSON protocol container sizes - `BaseProtocol#skip` container handling - generated struct/union container reads - `BaseTransport#read_all` - `MemoryBufferTransport#read_all` - native accelerated binary protocol and struct paths The native memory buffer path also gets a direct `read_all` implementation so the added guard does not force hot binary reads through the slower generic transport path. The public protocol interface stays unchanged. ## Performance Pure Ruby benchmark, helper-call baseline vs inline guard: ``` rb-bin-read-large -3.39% rb-bin-read-small -2.01% ``` Native-enabled sanity run: ``` c-bin-read-large +1.18% (3-sample noisy run) c-bin-read-small -1.25% rb-bin-read-large -1.00% rb-bin-read-small -1.01% ``` <!-- We recommend you review the checklist/tips before submitting a pull request. --> - [x] Did you create an [Apache Jira](https://issues.apache.org/jira/projects/THRIFT/issues/) ticket? [THRIFT-6025](https://issues.apache.org/jira/browse/THRIFT-6025) - [x] If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"? - [x] Did you squash your changes to a single commit? (not required, but preferred) - [x] Did you do your best to avoid breaking changes? If one was needed, did you label the Jira ticket with "Breaking-Change"? - [ ] If your change does not involve any code, include `[skip ci]` anywhere in the commit message to free up build resources. <!-- The Contributing Guide at: https://github.com/apache/thrift/blob/master/CONTRIBUTING.md has more details and tips for committing properly. --> -- 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]
