fix(parquet): avoid panic on ColumnIndex length mismatch#9833
Open
pchintar wants to merge 1 commit intoapache:mainfrom
Open
fix(parquet): avoid panic on ColumnIndex length mismatch#9833pchintar wants to merge 1 commit intoapache:mainfrom
pchintar wants to merge 1 commit intoapache:mainfrom
Conversation
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.
Which issue does this PR close?
Rationale for this change
In
parquet/src/file/page_index/column_index.rs,ColumnIndexdecoding assumes that page-aligned arrays (null_pages,min_values,max_values, and optional arrays) have matching lengths, but this is not validated.As a result, malformed metadata can trigger an out-of-bounds panic during decoding instead of returning a
ParquetError. Since parquet files are external input, this should be handled safely.What changes are included in this PR?
Added validation in:
PrimitiveColumnIndex::try_newByteArrayColumnIndex::try_newEnsures:
min_values.len() == null_pages.len()max_values.len() == null_pages.len()null_counts, histograms) are consistent with page countReturns
ParquetErroron mismatch instead of panickingAre these changes tested?
Yes.
Added a unit test:
test_column_index_rejects_mismatched_min_max_lengthsThis constructs a
ColumnIndexwith mismatched lengths and verifies that decoding returns an error instead of panicking.Are there any user-facing changes?
No.