You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Efuse::read_field_le and Efuse::read_field_be put no restrictions on the types that they can return, other than the Sized + 'static constraint. This means that types which require certain invariants to be upheld (such as references) can be constructed in ways which break those invariants and cause UB.
To Reproduce
Run cargo generate esp-rs/esp-template and create a new ESP32-S3 Rust binary.
I'm pretty certain that something along the lines of AnyBitPattern would be sufficient. The safety requirements for implementing that trait rule out things like references and bools, while also letting esp_hal continue to use those methods as it currently does, since all uses are with types that implement AnyBitPattern.
Bug description
Efuse::read_field_le
andEfuse::read_field_be
put no restrictions on the types that they can return, other than theSized + 'static
constraint. This means that types which require certain invariants to be upheld (such as references) can be constructed in ways which break those invariants and cause UB.To Reproduce
cargo generate esp-rs/esp-template
and create a new ESP32-S3 Rust binary.src/main.rs
cargo run --release
Example
This example also works on the
main
branch, as well.Output
Expected behavior
Using
Efuse::read_field_{le, be}
to construct arbitrary types should be prevented to not cause UB.Environment
The text was updated successfully, but these errors were encountered: