Skip to content

THRIFT-6133: Handle oversized Ruby memory-buffer reads - #3690

Merged
kpumuk merged 1 commit into
apache:masterfrom
kpumuk:rb-native-read-overflow
Jul 30, 2026
Merged

THRIFT-6133: Handle oversized Ruby memory-buffer reads#3690
kpumuk merged 1 commit into
apache:masterfrom
kpumuk:rb-native-read-overflow

Conversation

@kpumuk

@kpumuk kpumuk commented Jul 30, 2026

Copy link
Copy Markdown
Member

Native MemoryBufferTransport converted read sizes to a signed C integer before checking the bytes available. Positive Compact lengths above INT_MAX therefore raised RangeError instead of reporting truncated input.

The native implementation now preserves the requested Compact length through the availability check and returns EOFError for truncated oversized read and read_all calls, matching pure Ruby behavior.

  • Did you create an Apache Jira ticket? (THRIFT-6133)
  • If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"?
  • Did you squash your changes to a single commit? (not required, but preferred)
  • 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.

Client: rb

Co-Authored-By: OpenAI Codex (GPT-5.6) <codex@openai.com>
Copilot AI review requested due to automatic review settings July 30, 2026 13:52

This comment was marked as spam.

@kpumuk

kpumuk commented Jul 30, 2026

Copy link
Copy Markdown
Member Author

Fuzzer crash:


Running: /mnt/scratch0/clusterfuzz/bot/inputs/fuzzer-testcases/crash-29d1631cf96f7c2f537740ee480968f6459d51bf
--
  | /mnt/scratch0/clusterfuzz/bot/builds/clusterfuzz-builds_thrift-rb_0e62be81ffe482a27e2d02fba3412b99b470d7a9/revisions/thrift/lib/rb/lib/thrift/protocol/base_protocol.rb:360:in `read_all': integer 3397380576 too big to convert to `int' (RangeError)
  | from /mnt/scratch0/clusterfuzz/bot/builds/clusterfuzz-builds_thrift-rb_0e62be81ffe482a27e2d02fba3412b99b470d7a9/revisions/thrift/lib/rb/lib/thrift/protocol/base_protocol.rb:360:in `read_string'
  | from /mnt/scratch0/clusterfuzz/bot/builds/clusterfuzz-builds_thrift-rb_0e62be81ffe482a27e2d02fba3412b99b470d7a9/revisions/thrift/lib/rb/lib/thrift/protocol/base_protocol.rb:360:in `skip'
  | from /mnt/scratch0/clusterfuzz/bot/builds/clusterfuzz-builds_thrift-rb_0e62be81ffe482a27e2d02fba3412b99b470d7a9/revisions/thrift/lib/rb/lib/thrift/protocol/base_protocol.rb:368:in `skip'
  | from /mnt/scratch0/clusterfuzz/bot/builds/clusterfuzz-builds_thrift-rb_0e62be81ffe482a27e2d02fba3412b99b470d7a9/revisions/thrift/lib/rb/lib/thrift/protocol/base_protocol.rb:368:in `skip'
  | from /mnt/scratch0/clusterfuzz/bot/builds/clusterfuzz-builds_thrift-rb_0e62be81ffe482a27e2d02fba3412b99b470d7a9/revisions/thrift/lib/rb/lib/thrift/protocol/base_protocol.rb:368:in `skip'
  | from /mnt/scratch0/clusterfuzz/bot/builds/clusterfuzz-builds_thrift-rb_0e62be81ffe482a27e2d02fba3412b99b470d7a9/revisions/thrift/lib/rb/lib/thrift/protocol/base_protocol.rb:368:in `skip'
  | from /mnt/scratch0/clusterfuzz/bot/builds/clusterfuzz-builds_thrift-rb_0e62be81ffe482a27e2d02fba3412b99b470d7a9/revisions/thrift/lib/rb/lib/thrift/protocol/base_protocol.rb:368:in `skip'
  | from /mnt/scratch0/clusterfuzz/bot/builds/clusterfuzz-builds_thrift-rb_0e62be81ffe482a27e2d02fba3412b99b470d7a9/revisions/thrift/lib/rb/lib/thrift/protocol/base_protocol.rb:391:in `block in skip'
  | from <internal:numeric>:237:in `times'
 ```

@mergeable mergeable Bot added the ruby Pull requests that update Ruby code label Jul 30, 2026
@kpumuk
kpumuk merged commit 64601a5 into apache:master Jul 30, 2026
95 checks passed
@kpumuk
kpumuk deleted the rb-native-read-overflow branch July 30, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ruby Pull requests that update Ruby code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants