notify-rs / notify

🔭 Cross-platform filesystem notification library for Rust.
https://docs.rs/notify
2.76k stars 222 forks source link

Fix unaligned access to FILE_NOTIFY_INFORMATION #647

Open ruihe774 opened 1 month ago

ruihe774 commented 1 month ago

In some environments (e.g. wine), FILE_NOTIFY_INFORMATION is packed placed and is unaligned. Reading from unaligned FILE_NOTIFY_INFORMATION is a UB and causes panics in debug builds. This PR workarounds this issue by using ptr::read_unaligned.

dfaust commented 1 month ago

Thanks. Unfortunately offset_of has only been stabilized in Rust 1.77 and our MSRV is 1.72. My suggestion: I'm going to branch off and release a new version today and then merge this PR into main afterwards.

CC: @0xpr03 @JohnTitor

ruihe774 commented 4 weeks ago

Thanks. Unfortunately offset_of has only been stabilized in Rust 1.77 and our MSRV is 1.72. My suggestion: I'm going to branch off and release a new version today and then merge this PR into main afterwards.

CC: @0xpr03 @JohnTitor

We can hard code the offset giving FILE_NOTIFY_INFORMATION has a stable ABI; somewhat dirty, though.