fix(arrow): bound read_len_prefixed_bytes by the available bytes - #8967
Open
jackylee-ch wants to merge 1 commit into
Open
fix(arrow): bound read_len_prefixed_bytes by the available bytes#8967jackylee-ch wants to merge 1 commit into
jackylee-ch wants to merge 1 commit into
Conversation
The 8-byte length prefix is untrusted, but the reader allocated for it before consuming anything, so a corrupt prefix panicked with "capacity overflow" instead of returning an error. read_len_prefixed_bytes_at, documented as its pair over the same wire format, already rejects the same bytes cleanly. Read through Take::read_to_end and compare what arrived against what was declared, and add tests asserting both readers reach the same verdict.
Contributor
There was a problem hiding this comment.
✅ Gate recommendation: approve.
The reader now allocates in proportion to bytes actually produced while the declared length still bounds consumption, so corrupt or truncated inputs return an I/O error without changing the wire format, successful reads, or trailing-byte behavior.
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.
read_len_prefixed_bytesreads an 8-byte length prefix and then allocates for it before consuming a single byte, so a corrupt prefix panics withcapacity overflowrather than returning an error.read_len_prefixed_bytes_at— documented as its pair over the same wire format — rejects the identical bytes cleanly:Read through
Take::read_to_endand compare what arrived against what was declared. The tests run the same bytes through both readers and assert they agree, plus round trips and truncated-prefix cases.