Skip to content

fix(arrow): bound read_len_prefixed_bytes by the available bytes - #8967

Open
jackylee-ch wants to merge 1 commit into
lance-format:mainfrom
jackylee-ch:fix/ipc-length-validation
Open

fix(arrow): bound read_len_prefixed_bytes by the available bytes#8967
jackylee-ch wants to merge 1 commit into
lance-format:mainfrom
jackylee-ch:fix/ipc-length-validation

Conversation

@jackylee-ch

Copy link
Copy Markdown
Contributor

read_len_prefixed_bytes reads an 8-byte length prefix and then allocates for it before consuming a single byte, so a corrupt prefix panics with capacity overflow rather than returning an error. read_len_prefixed_bytes_at — documented as its pair over the same wire format — rejects the identical bytes cleanly:

read_len_prefixed_bytes(0xFF..FF)    -> panic  "capacity overflow"
read_len_prefixed_bytes_at(0xFF..FF) -> Err    "length-prefixed bytes: truncated data"

Read through Take::read_to_end and 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.

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.
@github-actions github-actions Bot added the bug Something isn't working label Sep 3, 2026

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant