runes icon indicating copy to clipboard operation
runes copied to clipboard

Unsound implementation in `load_prefix<T>` and `save_prefix<T>`

Open shinmao opened this issue 2 years ago • 1 comments
trafficstars

https://github.com/Determinant/runes/blob/fd12a0a915ca52e1f65b917feb46f28194328e33/src/utils.rs#L71-L75 Hi, I consider that load_prefix and save_prefix could have unsound implementation. At line 72, users could transmute arbitrary types to byte slice. However, if the types contains padding bytes, consider it as u8 could lead to undefined behavior. Based on the safety part in doc, callers are required to make sure the data points to initialized values while the function here didn't guarantee the safety.

shinmao avatar Aug 30 '23 22:08 shinmao

Yes. This project was written a while back when I was picking up Rust. Feel free to submit a PR to fix it and I'll merge it. Thanks!

Determinant avatar Feb 23 '25 11:02 Determinant