when setting a device name using VirtualDeviceBuilder::name(), the crate attempts to write to an unaligned pointer, causing UB, this i believe occurs specifically when copying the device name string into the uinput_setup struct
to reproduce:
- create a minimal device
use evdev::{uinput::VirtualDevice, UinputAbsSetup};
fn main() -> Result<()> {
VirtualDevice::builder()?
.name("test device name") // Triggers UB
.build()?;
Ok(())
}
- run it under a debugger
- look for the following error message(for context i used lldb added a br at VirtualDevice::builder(), then inspected val.name.data_ptr)
unaligned pointer: ptr::read_volatile requires aligned pointer
unsafe precondition violated: is_aligned_to: align is not a power-of-two
Expected behaviour
the crate should safely handle string copying without triggering unaligned access UB