Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fixed UB in big5::tests::test_big5_decode flagged by Miri. #53

Merged
merged 1 commit into from
Aug 24, 2020

Conversation

YoshikiTakashima
Copy link
Contributor

Fixes the out-of-bound UB in #52.

Looks like replacing dst.add with dst.wrapping_add is sufficient to stop UB from occurring, while passing all existing test cases.

Run
cargo miri test -- -Zmiri-disable-alignment-check -- big5::tests::test_big5_decode to confirm that the UB is fixed.

@hsivonen
Copy link
Owner

Thank you for looking into this.

Indeed, add here may compute a pointer that's outside the allocation bounds even if that pointer is never dereferenced, and wrapping_add is the right fix. The name of the wrapping_add methods is kinda weird for a pointer, but the documentation checks out.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants