fix(arrow/scalar): reject negative indices in GetScalar#4
Closed
fornwall wants to merge 1 commit into
Closed
Conversation
GetScalar only guarded the upper bound (idx >= arr.Len()), and the IsNull(idx) call ran before that check, so a negative index panicked inside the null-bitmap lookup instead of returning an error. Check both bounds first and return arrow.ErrIndex for any out-of-range index. Signed-off-by: Fredrik Fornwall <fredrik@fornwall.net>
d837cb9 to
6bec180
Compare
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.
Split out from the review of apache#936.
scalar.GetScalaronly guarded the upper bound (idx >= arr.Len()), and theIsNull(idx)call ran before that check, so a negative index panicked inside the null-bitmap lookup instead of returning an error. This checks both bounds first and returnsarrow.ErrIndexfor any out-of-range index.Complements upstream 950bc29 (apache#927), which validates dictionary scalar indices in
Dictionary.ValidateFull/GetEncodedValue; this hardens the underlyingGetScalarentry point itself, as suggested in the apache#936 review ("A follow-up hardening scalar.GetScalar/GetEncodedValue to reject negative indices library-wide would be even better").🤖 Generated with Claude Code
https://claude.ai/code/session_016sey3gTdMfZ9LbLw3BvFJE