Skip to content

Conversation

@rambleraptor
Copy link
Contributor

fix: Check level byte length to avoid panic

We've found a panic in our testing in these certain areas. I've added tests to help show when the errors would be thrown.

@github-actions github-actions bot added the parquet Changes to the parquet crate label Nov 20, 2025
Copy link
Contributor

@etseidl etseidl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rambleraptor, this looks good. Just a few micro-optimizations to consider 😅

If this is erroring for you, it makes me want to check farther upstream and see if we can detect this when we decode the page header.

@@ -437,6 +437,9 @@ where
let mut offset = 0;

if max_rep_level > 0 {
if offset > buf.len() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should never evaluate true?

}

if offset > buf.len() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the checks above are moved to after offset is incremented, then I think this check can be eliminated as it will either always be true (offset is still 0), or the error condition was already caught.

}

let def_levels_end = rep_levels_byte_len + def_levels_byte_len;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not move this check higher up and check all levels in one shot?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parquet Changes to the parquet crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants