usb-device icon indicating copy to clipboard operation
usb-device copied to clipboard

Errors during get_configuration_descriptors get silently eaten

Open lkolbly opened this issue 4 years ago • 0 comments

https://github.com/mvirkkunen/usb-device/blob/258ad5b9e44b6ef9b0b7fa55254b12db0a53fc3f/src/device.rs#L413-L417

If get_configuration_descriptors throws an error (e.g. because of a buffer overflow), the error will exit the .accept() call and then get dropped by the .ok() (which will convert errors to None and drop the error). This makes it somewhat more difficult to debug when the configuration descriptors are too long (for example).

I'm not entirely sure what the correct behaviour should be. One option would be to unwrap() and panic (which is probably reasonable here, since it'll always panic essentially when the device boots, so it's easy to detect). The other option would be to make get_descriptor (and therefore control_in) return Result, which is probably the much more invasive solution (it'd be difficult to integrate with various class drivers).

lkolbly avatar Mar 14 '21 16:03 lkolbly