Skip to content

fix: Bound large list view elements without overflowing int64_t - #1005

Merged
paleolimbot merged 1 commit into
apache:mainfrom
pedrobtz:fix-list-view-bound-overflow
Nov 5, 2026
Merged

paleolimbot merged 1 commit into
apache:mainfrom
pedrobtz:fix-list-view-bound-overflow

Conversation

@pedrobtz

@pedrobtz pedrobtz commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

ArrowArrayViewValidateFull() bounds each list view and large list view element as offset + size > child_len. Both values have already been checked to be non-negative, but for a large list view two large values overflow the int64_t sum, 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 as signed integer overflow: 9223372036854775807 + 9223372036854775807 cannot be represented in type 'int64_t'. The check is now size > child_len - offset, which cannot overflow once both are non-negative. The error message is unchanged.

ArrayViewTestLargeListView now also validates an element with offset and size both INT64_MAX against a child of length 1. It expects EINVAL and the usual message. Without the fix, full validation returns NANOARROW_OK and 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.

ctest passes 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

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-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.53%. Comparing base (9bf2d88) to head (ccf0d8c).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@paleolimbot paleolimbot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@paleolimbot
paleolimbot merged commit 85517e3 into apache:main Nov 5, 2026
43 of 44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants