Commit ba7dada
authored
fix(parquet): avoid panic on ColumnIndex length mismatch (#9833)
# Which issue does this PR close?
- Closes #9832 .
# Rationale for this change
In `parquet/src/file/page_index/column_index.rs`, `ColumnIndex` decoding
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_new`
* `ByteArrayColumnIndex::try_new`
* Ensures:
* `min_values.len() == null_pages.len()`
* `max_values.len() == null_pages.len()`
* optional arrays (`null_counts`, histograms) are consistent with page
count
* Returns `ParquetError` on mismatch instead of panicking
# Are these changes tested?
Yes.
Added a unit test:
* `test_column_index_rejects_mismatched_min_max_lengths`
This constructs a `ColumnIndex` with mismatched lengths and verifies
that decoding returns an error instead of panicking.
# Are there any user-facing changes?
No.1 parent fe3c0c9 commit ba7dada
1 file changed
Lines changed: 80 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
109 | 139 | | |
110 | 140 | | |
111 | 141 | | |
| |||
295 | 325 | | |
296 | 326 | | |
297 | 327 | | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
298 | 358 | | |
299 | 359 | | |
300 | 360 | | |
| |||
738 | 798 | | |
739 | 799 | | |
740 | 800 | | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
741 | 821 | | |
0 commit comments