Repository navigation
MINOR: Reject negative first offsets in ValidateVectorDataVisitor - #1532
Merged
Merged
Conversation
Arawoof06
requested review from
jbonofre,
laurentgo,
lidavidm and
wgtmac
as code owners
November 29, 2026 18:35
This comment has been minimized.
This comment has been minimized.
jbonofre
approved these changes
Nov 30, 2026
jbonofre
left a comment
Member
There was a problem hiding this comment.
Thanks for the fix! Checking prevValue >= 0 at position 0 in both validateOffsetBuffer and validateLargeOffsetBuffer closes the gap while still allowing valid non-zero initial offsets (e.g. for sliced vectors) and empty vectors (valueCount == 0). The test coverage across VarBinaryVector, LargeVarBinaryVector, ListVector, and LargeListVector looks solid.
LGTM!
Contributor
Author
|
Appreciate the quick review and the merge. |
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.
What's Changed
ValidateVectorDataVisitor.validateOffsetBufferscans the offset buffer from position 1 and usesoffsets[0]only to seedprevValue, so the first offset is never checked for being non-negative.validateLargeOffsetBufferhas the same gap. A negative first offset leaves the remaining offsets non-decreasing and the last offset inside the data buffer, which is allValidateVectorBufferVisitorcompares, soValueVectorUtility.validateFullaccepts the vector. That coversVarCharVector/VarBinaryVector, their large variants andListVector/LargeListVector, which take their offsets verbatim from IPC input, andvalidateFullis whatArrowReader.setValidateBatches(true)runs on an untrusted stream. Arrow C++ValidateOffsetsrejects a negative first offset.A
VarBinaryVectorholdingaaa,bbbwithoffsets[0]set to -8 passesvalidateFulltoday, and reading it then goes below the data buffer:With
arrow.enable_unsafe_memory_access=trueno bounds check is left, and the eight bytes planted in front of the data buffer come back as part of the value:Both helpers now check position 0 the way they already check the rest of the buffer. A vector whose first offset is 0 behaves as before.
testValidateNegativeFirstOffsetexercises the int and long helpers throughVarBinaryVector,LargeVarBinaryVector,ListVectorandLargeListVector, and fails onmain. Thevector,algorithm,compressionandadapter/jdbcsuites pass, and spotless and checkstyle are clean.