-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Check level byte length to avoid panic #8889
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
etseidl
left a comment
There was a problem hiding this 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() { | |||
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
|
Hi @rambleraptor , will you have time to address @etseidl 's comments for this PR or shall we plan to do it as a follow on PR? |
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.