Skip to content
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

der: fix handling of oversized unsigned INTEGER inputs #447

Merged
merged 1 commit into from
Feb 24, 2022

Conversation

tarcieri
Copy link
Member

The previous implementation used saturating_sub rather than checked_sub to compute the number of leading zeroes to use, which would cause a panic if the input exceeded the output (see #446).

This commit switches to checked_sub, returning ErrorKind::Length in the event the output buffer is too small for the given input. It also adds unit tests for this behavior as well as the happy paths.

The previous implementation used `saturating_sub` rather than
`checked_sub` to compute the number of leading zeroes to use, which
would cause a panic if the input exceeded the output (see #446).

This commit switches to `checked_sub`, returning `ErrorKind::Length` in
the event the output buffer is too small for the given input. It also
adds unit tests for this behavior as well as the happy paths.
@tarcieri tarcieri merged commit 9d902f0 into master Feb 24, 2022
@tarcieri tarcieri deleted the der/handle-oversized-integer-inputs branch February 24, 2022 21:08
bstrie added a commit to bstrie/trophy-case that referenced this pull request Feb 27, 2022
bstrie added a commit to bstrie/trophy-case that referenced this pull request Feb 27, 2022
@tarcieri tarcieri mentioned this pull request May 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant