Skip to content

Commit 49ed6ef

Browse files
authored
Add bit width check (#8888)
1 parent 73dbd55 commit 49ed6ef

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

parquet/src/encodings/decoding.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,10 @@ where
681681
.try_into()
682682
.map_err(|_| general_err!("invalid 'mini_blocks_per_block'"))?;
683683

684+
if self.mini_blocks_per_block == 0 {
685+
return Err(general_err!("cannot have zero miniblocks per block"));
686+
}
687+
684688
self.values_left = self
685689
.bit_reader
686690
.get_vlq_int()
@@ -1688,6 +1692,21 @@ mod tests {
16881692
test_delta_bit_packed_decode::<Int64Type>(data);
16891693
}
16901694

1695+
#[test]
1696+
fn test_delta_bit_packed_zero_miniblocks() {
1697+
// It is invalid for mini_blocks_per_block to be 0
1698+
let data = vec![
1699+
128, 1, // block_size = 128
1700+
0, // mini_blocks_per_block = 0
1701+
];
1702+
let mut decoder = DeltaBitPackDecoder::<Int32Type>::new();
1703+
let err = decoder.set_data(data.into(), 0).unwrap_err();
1704+
assert_eq!(
1705+
err.to_string(),
1706+
"Parquet error: cannot have zero miniblocks per block"
1707+
);
1708+
}
1709+
16911710
#[test]
16921711
fn test_delta_bit_packed_decoder_sample() {
16931712
let data_bytes = vec![

0 commit comments

Comments
 (0)