RustAudio / vst-rs

VST 2.4 API implementation in rust. Create plugins or hosts. Previously rust-vst on the RustDSP group.
MIT License
1.04k stars 91 forks source link

SysExEvent contains invalid data on 64-bit systems #170

Closed helgoboss closed 3 years ago

helgoboss commented 3 years ago

There seems to be an issue with the current implementation of reading incoming SysEx: Iterating over vst::api::Events::events() produces SysExEvents that contain bytes as payload which are not the sys-ex bytes to be expected.

As far as I can tell, the problem is that the iterator creates copies of vst::api::Event values. On 64-bit systems, the vst::api::Event struct is smaller than the vst::api::SysExEvent struct: The _reserved field of vst::api::Event is 16 bytes large whereas the 4 last fields of vst::api::SysExEvent (the counterpart of _reserved) have a size of in total 1 4 + 3 8 = 28 bytes. When creating a copy of vst::api::Event, these extra bytes are just skipped. Result: When the copy is casted back to vst::api::SysExEvent, the system_data pointer will contain arbitrary data. Dereferencing it will deliver unexpected results.

Tested in REAPER on Windows x64.

PR on the way.