-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Correctly read from a possibly misaligned pointer #615
Conversation
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.
I’m not an expert but this looks great to me. While we’re here, would you mind checking that within wasi-common
that’s all potential cases of misaligned pointers handled?
I think these were the only places reported by clippy, but I'll recheck. |
Awesome, thanks a bunch! :-) |
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.
I was expecting this would be solved by aligning the buffer, since we're in control of that, however it appears Rust doesn't have nice ways to do that. But write_unaligned
works too.
This reapplies #615, which was inadvertently reverted.
This reapplies #615, which was inadvertently reverted.
* Correctly handle possibly misaligned pointers in readdir This reapplies #615, which was inadvertently reverted. * Tidy up unneeded `self::` qualifiers. * Make Dir's contents private. Also remove the `unsafe` from `impl_iter`. With `Dir`'s field being private, we can rely on the pointer being only what we've assigned to it. * Make `poll`'s timeout argument a `libc::c_int`. This clarifies that there are no subsequent conversions before calling the underlying libc API. * Use clock_gettime instead of clock_getres to get the time. * Mark FileType::from_raw as safe. It handles unknown values, so it can be marked safe.
This was reported in #513.
read_unaligned
is definitely the most ergonomic solution but clippy still marks this as an error, see rust-lang/rust-clippy#2881 for more details.I also fixed a potentially misaligned write in the implementation of
fd_readdir
.I can't ask for reviewers, so cc @kubkon @sunfishcode @peterhuene