pchintar commented on code in PR #9797:
URL: https://github.com/apache/arrow-rs/pull/9797#discussion_r3132459363
##########
parquet/src/encodings/decoding.rs:
##########
@@ -1134,7 +1134,22 @@ impl<T: DataType> Decoder<T> for
DeltaByteArrayDecoder<T> {
let suffix = v[0].data();
// Extract current prefix length, can be 0
- let prefix_len = self.prefix_lengths[self.current_idx] as
usize;
+ let prefix_len_i32 = self.prefix_lengths[self.current_idx];
+ if prefix_len_i32 < 0 {
+ return Err(general_err!(
+ "Invalid DELTA_BYTE_ARRAY prefix length {}",
+ prefix_len_i32
+ ));
+ }
+ let prefix_len = prefix_len_i32 as usize;
Review Comment:
Thanks @etseidl for the suggestion — updated to use `usize::try_from(...)`
with proper error mapping.
Also added an additional test
`test_delta_byte_array_negative_prefix_len_returns_error` to cover the negative
prefix length case so that path is now exercised as well.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]