Skip to content

Bound the stripe statistics index in startNextStripe and getStripeStatistics - #34

Merged
PedroTadim merged 1 commit into
ClickHouse:mainfrom
groeneai:orc-missing-stripe-statistics-main
Oct 8, 2026
Merged

PedroTadim merged 1 commit into
ClickHouse:mainfrom
groeneai:orc-missing-stripe-statistics-main

Conversation

@groeneai

@groeneai groeneai commented Oct 8, 2026

Copy link
Copy Markdown

Same change as #33 on ClickHouse/2.3.1, for main.

What changes were proposed in this pull request?

RowReaderImpl::startNextStripe evaluates the stripe statistics only when stripe_stats_size() == stripes_size(); otherwise the stripes are read without stripe-level filtering, as for a file with no Metadata. ReaderImpl::getStripeStatistics throws ParseError on that count mismatch and InvalidArgument for an out-of-range stripe index.

The only difference from #33: on main, getStripeStatistics reads stripe_stats(stripeIndex) before the stripe footer, so both checks go right after the metadata == nullptr check.

Why are the changes needed?

A Metadata section can parse into fewer entries than the footer has stripes (ClickHouse/ClickHouse#124238), and both functions then index stripe_stats out of range.

How was this patch tested?

Standalone Debug build of main, before and after, with the crafted files from ClickHouse/ClickHouse#124315:

  • Reading with the search argument id < 5: before, protobuf CHECK failed: (index) < (current_size_) on both files; after, the same rows as a valid file.
  • getStripeStatistics: before, the same protobuf check for a bad index or a file with no entries, and stripe 1's entry returned for stripe 0 of the two-stripe file; after, ParseError / InvalidArgument, and valid files still return their statistics.
  • orc-test: 740/740 before and after.

The issue's own reproducer is already rejected on main (Failed to parse the metadata), so only the crafted files reach these reads here.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Opus 5.5

…tistics

Same change as ClickHouse#33 on ClickHouse/2.3.1 (2195561).

A Metadata section with fewer entries than the footer has stripes (for
example after a corrupt PostScript metadataLength) made
RowReaderImpl::startNextStripe read stripe_stats(currentStripe_) out of
bounds when a search argument was set. Entries are matched to stripes only
by position, so startNextStripe now evaluates stripe statistics only when
there is one entry per stripe; otherwise it reads the stripe without
stripe-level filtering, as for a file with no Metadata.

getStripeStatistics throws ParseError on a count mismatch and
InvalidArgument on an out-of-range stripe index. On main it reads
stripe_stats(stripeIndex) before the stripe footer, so both checks go
right after the metadata check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the CPP label Oct 8, 2026
@PedroTadim
PedroTadim merged commit 092c204 into ClickHouse:main Oct 8, 2026
14 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants