Repository navigation
fix: Bound large list view elements without overflowing int64_t - #1005
Merged
Merged
Conversation
ArrowArrayViewValidateFull() checked a large list view element as offset + size > child_len. Two large non-negative values overflow that sum, so a wrapped result passed the check. Compare size against child_len - offset instead, which cannot overflow once both are known to be non-negative. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1005 +/- ##
=======================================
Coverage 78.53% 78.53%
=======================================
Files 106 106
Lines 17206 17206
Branches 2064 2064
=======================================
Hits 13513 13513
Misses 2431 2431
Partials 1262 1262 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
ArrowArrayViewValidateFull()bounds each list view and large list view element asoffset + size > child_len. Both values have already been checked to be non-negative, but for a large list view two large values overflow theint64_tsum, which is undefined behaviour. In practice the sum wraps to a negative number, so an element that points far past the child passes full validation. UBSan reports it assigned integer overflow: 9223372036854775807 + 9223372036854775807 cannot be represented in type 'int64_t'. The check is nowsize > child_len - offset, which cannot overflow once both are non-negative. The error message is unchanged.ArrayViewTestLargeListViewnow also validates an element with offset and size bothINT64_MAXagainst a child of length 1. It expectsEINVALand the usual message. Without the fix, full validation returnsNANOARROW_OKand the test fails, and under UBSan it stops at the addition.The input was found by fuzzing the IPC reader in the zuarrow R package, which vendors nanoarrow.
ctestpasses in a plain build and with ASan and UBSan (410 tests). The changed files are formatted with the pinned clang-format 16.0.6.🤖 Generated with Claude Code