Repository navigation
Conversation
…lidation Minimal validation allows a zero-length array to have an offsets buffer shorter than one offset. Default validation then read a full offset from it. Read offsets only when the buffer holds them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pedrobtz
force-pushed
the
fix-validate-short-offsets
branch
from
October 22, 2026 15:27
0d2ccc3 to
c49e8c7
Compare
This branch has not been deployed
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.
ArrowArrayViewValidateMinimal()deliberately allows an empty offsets buffer for a zero-length array. Its minimum size is(offset_plus_length != 0) * element_size * (offset_plus_length + 1), which is 0 for a zero-length array. So a buffer of 1 to 3 bytes (or 1 to 7 for the large types) passes.ArrowArrayViewValidateDefault()then reads offsets wheneversize_bytes != 0, which reads a wholeint32_torint64_tpast the end of the buffer.Default validation now reads the first and last offsets only when the buffer holds
offset_plus_length + 1of them. This applies to string and binary, large string and binary, list and map, and large list. A buffer that is long enough behaves as before. A too-short buffer for a zero-length array is treated like an empty one.The new
ArrayViewTestShortOffsetsBuffertest validates a zero-length string, large string, list and large list. Each has an offsets buffer one byte short of a single offset, in a heap allocation of exactly that size. Without the fix, ASan reports a heap-buffer-overflow. With it, all four validate.The input was found by fuzzing the IPC reader in the zuarrow R package, which vendors nanoarrow. An IPC message can declare a 2-byte offsets buffer for a zero-length string column.
ctestpasses in a plain Debug build and with ASan and UBSan (410 tests each). The changed files are formatted with the pinned clang-format 16.0.6.🤖 Generated with Claude Code