You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "dhruvxvaishnav (via GitHub)" <gi...@apache.org> on 2026/08/18 09:56:45 UTC
[PR] Fix: Validate dictionary index bit width in Parquet reader [arrow-rs]
dhruvxvaishnav opened a new pull request, #10725:
URL: https://github.com/apache/arrow-rs/pull/10725
# Which issue does this PR close?
- Closes #10722.
# Rationale for this change
When reading dictionary-encoded Parquet data pages with DictIndexDecoder or ByteArrayDictionaryReader, the first byte was read via data[0] without checking if data is empty, and the index it_width was passed to RleDecoder without checking the
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix: Error rather than panic on invalid dictionary index bit width in Parquet reader [arrow-rs]
Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on code in PR #10725:
URL: https://github.com/apache/arrow-rs/pull/10725#discussion_r3807401431
##########
parquet/src/arrow/decoder/dictionary_index.rs:
##########
@@ -43,7 +43,14 @@ impl DictIndexDecoder {
/// Create a new [`DictIndexDecoder`] with the provided data page, the number of levels
/// associated with this data page, and the number of non-null values (if known)
pub fn new(data: Bytes, num_levels: usize, num_values: Option<usize>) -> Result<Self> {
- let bit_width = data[0];
+ let bit_width = *data
+ .first()
+ .ok_or_else(|| general_err!("dictionary index page is empty"))?;
+ if bit_width > 32 {
Review Comment:
Maybe add a constant somewhere (`MAX_RLE_DICTIONARY_BIT_WIDTH` 🤷).
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix: Error rather than panic on invalid dictionary index bit width in Parquet reader [arrow-rs]
Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on PR #10725:
URL: https://github.com/apache/arrow-rs/pull/10725#issuecomment-5348104561
Thanks @dhruvxvaishnav (and @alamb and @Rich-T-kid for reviews)
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix: Error rather than panic on invalid dictionary index bit width in Parquet reader [arrow-rs]
Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl merged PR #10725:
URL: https://github.com/apache/arrow-rs/pull/10725
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix: Error rather than panic on invalid dictionary index bit width in Parquet reader [arrow-rs]
Posted by "dhruvxvaishnav (via GitHub)" <gi...@apache.org>.
dhruvxvaishnav commented on code in PR #10725:
URL: https://github.com/apache/arrow-rs/pull/10725#discussion_r3810148977
##########
parquet/src/arrow/decoder/dictionary_index.rs:
##########
@@ -43,7 +43,14 @@ impl DictIndexDecoder {
/// Create a new [`DictIndexDecoder`] with the provided data page, the number of levels
/// associated with this data page, and the number of non-null values (if known)
pub fn new(data: Bytes, num_levels: usize, num_values: Option<usize>) -> Result<Self> {
- let bit_width = data[0];
+ let bit_width = *data
+ .first()
+ .ok_or_else(|| general_err!("dictionary index page is empty"))?;
+ if bit_width > 32 {
Review Comment:
Added MAX_RLE_DICTIONARY_BIT_WIDTH = 32 in parquet::encodings::rle and updated DictIndexDecoder, ByteArrayDictionaryReader (DictionaryDecoder), and DictDecoder to use it.
##########
parquet/src/encodings/rle.rs:
##########
@@ -361,6 +361,7 @@ pub struct RleDecoder {
impl RleDecoder {
pub fn new(bit_width: u8) -> Self {
+ debug_assert!(bit_width <= 64, "Bit width must be <= 64");
Review Comment:
`RleDecoder` is a generic Parquet RLE / bit-packing hybrid decoder that supports unpacking values up to 64 bits wide (using a `u64` internal accumulator). However, Parquet dictionary indices are 32-bit signed integers (`i32`), so dictionary index bit widths are bounded by `MAX_RLE_DICTIONARY_BIT_WIDTH` (32). I have added doc comments on `RleDecoder::new` and `MAX_RLE_DICTIONARY_BIT_WIDTH` explaining this distinction.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix: Error rather than panic on invalid dictionary index bit width in Parquet reader [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #10725:
URL: https://github.com/apache/arrow-rs/pull/10725#discussion_r3806727415
##########
parquet/src/encodings/rle.rs:
##########
@@ -361,6 +361,7 @@ pub struct RleDecoder {
impl RleDecoder {
pub fn new(bit_width: u8) -> Self {
+ debug_assert!(bit_width <= 64, "Bit width must be <= 64");
Review Comment:
The checks above say 32 bits is the max, but this assert allows 64 -- why the discrepancy?
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix: Error rather than panic on invalid dictionary index bit width in Parquet reader [arrow-rs]
Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on PR #10725:
URL: https://github.com/apache/arrow-rs/pull/10725#issuecomment-5347182960
CI is backed up today...I'll merge this once it finishes
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix: Error rather than panic on invalid dictionary index bit width in Parquet reader [arrow-rs]
Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on code in PR #10725:
URL: https://github.com/apache/arrow-rs/pull/10725#discussion_r3807387090
##########
parquet/src/encodings/rle.rs:
##########
@@ -361,6 +361,7 @@ pub struct RleDecoder {
impl RleDecoder {
pub fn new(bit_width: u8) -> Self {
+ debug_assert!(bit_width <= 64, "Bit width must be <= 64");
Review Comment:
I think it's somehow related to delta binary, which uses bit packing up to 64 bits. But the current delta decoder doesn't use `RleDecoder` and instead uses `BitReader` directly. Kind of confusing.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org