Skip to content

Reject out-of-range column id in StripeInformationImpl::getColumnEncoding - #24

Merged
alexey-milovidov merged 1 commit into
ClickHouse:ClickHouse/2.1.2from
groeneai:fix-getcolumnencoding-out-of-range
Jul 19, 2026
Merged

Reject out-of-range column id in StripeInformationImpl::getColumnEncoding#24
alexey-milovidov merged 1 commit into
ClickHouse:ClickHouse/2.1.2from
groeneai:fix-getcolumnencoding-out-of-range

Conversation

@groeneai

Copy link
Copy Markdown

A corrupt or truncated ORC file can declare more columns in the file type tree than there are ColumnEncoding entries in the stripe footer. getColumnEncoding and getDictionarySize indexed stripeFooter_->columns(colId) directly, so such a column id hit an out-of-range protobuf RepeatedPtrField::Get and aborted the process via an absl CHECK (SIGABRT).

Bound-check the id against columns_size() and throw a ParseError instead, matching how the sibling stream accessors (getStreamInformation) already reject malformed footers.

Found via the ClickHouse AST fuzzer: a fuzzed ORC blob fed to format('ORC', ...) reaches getColumnEncoding through ClickHouse's schema inference (isDictionaryEncoded) for a STRING column and crashes the server. Repro (minimal ORC: root STRUCT with one STRING child, stripe footer with only 1 ColumnEncoding) now returns a clean parse error instead of aborting.

…ding

A corrupt or truncated ORC file can declare more columns in the file type tree
than there are ColumnEncoding entries in the stripe footer. getColumnEncoding
and getDictionarySize indexed stripeFooter_->columns(colId) directly, so such a
column id hit an out-of-range protobuf RepeatedPtrField::Get and aborted the
process via an absl CHECK. Bound-check the id against columns_size() and throw a
ParseError instead, matching how the sibling stream accessors reject malformed
footers.
@CLAassistant

CLAassistant commented Jul 14, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@groeneai

Copy link
Copy Markdown
Author

cc @Avogar — small ORC C++ library fix: bounds-check the column id in StripeInformationImpl::getColumnEncoding/getDictionarySize so a corrupt stripe footer throws ParseError instead of aborting the process. Surfaced by the ClickHouse AST fuzzer via ORC schema inference. Would appreciate a review.

@Avogar

Avogar commented Jul 14, 2026

Copy link
Copy Markdown
Member

@groeneai why does this PR contains so many commits? I think you made something wrong or used wrong targer branch

@groeneai
groeneai changed the base branch from main to ClickHouse/2.1.2 July 18, 2026 10:08
@groeneai

Copy link
Copy Markdown
Author

@Avogar sorry, wrong base branch. The PR was opened against main, but ClickHouse pins contrib/orc to the ClickHouse/2.1.2 branch, so it showed all of main's divergent history (59 commits, unrelated files, CLA from 13 authors).

Retargeted the base to ClickHouse/2.1.2. It is now the single intended commit: +17/-0 in c++/src/StripeStream.hh, and the CLA check is green. Ready for review.

@alexey-milovidov alexey-milovidov 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.

This is perfect!

@alexey-milovidov alexey-milovidov self-assigned this Jul 19, 2026
@alexey-milovidov
alexey-milovidov merged commit 2a54bf3 into ClickHouse:ClickHouse/2.1.2 Jul 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants