-
Notifications
You must be signed in to change notification settings - Fork 11
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
Soundness issue: Undefined Behavior due to writing to immutable pointer #36
Comments
Hi @RalfJung, thank you very much for alerting me to this, I guess I'll have to make these non-const for the time being, or hopefully I can find a way of keeping it const without UB that isn't much slower. |
…th array-element copying loop Fixes isaacholt100#36
Thanks a lot! |
No worries! Sure, can do, although the only major changes from 0.8 to 0.10 are the change from |
It's hard for me to say, I don't know the bnum ecosystem. The thing is just, the update from 0.8 to 0.10 has to be done by the author of the crate(s) that depend on 0.8 (and then the author of the next crate that depends on that, and so on). In contrast, an update to 0.8.1 can be done by anyone by just doing |
Thanks for explaining, I have now published v0.8.1 with this fix. |
Thanks :) |
I stumbled upon this code:
bnum/src/bint/endian.rs
Lines 85 to 92 in 6e26ddb
That code has UB:
uninit.as_ptr()
is a read-only pointer (it derives from a shared reference), and so it must not be written to. Just casting fromconst
tomut
does not help, you must use a proper mutable pointer here.copy_to_nonoverlapping
got stabilized accidentally; there isn't actually a way to use it inconst
on stable in a UB-free way.The text was updated successfully, but these errors were encountered: