Date: Sat, 08 Jun 2019 04:23:14 +0000 From: bugzilla-noreply@freebsd.org To: usb@FreeBSD.org Subject: [Bug 238412] libusb_get_config_descriptor() should return LIBUSB_NOT_FOUND on out-of-range config_index Message-ID: <bug-238412-19105@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D238412 Bug ID: 238412 Summary: libusb_get_config_descriptor() should return LIBUSB_NOT_FOUND on out-of-range config_index Product: Base System Version: 11.3-STABLE Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: usb Assignee: usb@FreeBSD.org Reporter: takahiro.kurosawa@gmail.com Created attachment 204897 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D204897&action= =3Dedit proposed patch libusb_get_config_descriptor() in FreeBSD issues a get_config_descriptor=20= =20=20=20=20=20=20 request even if the config_index argument is out of range. On the other=20= =20=20=20=20=20=20 hand, the function in Linux checks the config_index argument against=20=20= =20=20=20=20=20=20=20=20=20 bNumConfigurations in the device descriptor and returns LIBUSB_ERROR_NOT_FO= UND=20 without issuing get_config_descriptor requests.=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 It seems that get_config_descriptor requests with invalid config_index=20= =20=20=20=20=20=20=20=20 values for most USB devices fail, but there is a device (USB DrDAQ from=20= =20=20=20=20=20=20=20 Pico Technology) that does not check the config_index value. The request= =20=20=20=20=20=20 for USB DrDAQ succeeds even if the config_index value is invalid.=20=20=20= =20=20=20=20=20=20=20=20=20=20=20 As a result, the behavior of libusb_get_config_descriptor() in FreeBSD=20= =20=20=20=20=20=20=20=20 differs from the one in Linux on such a device.=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 This makes qemu hang on FreeBSD with USB passthrough enabled because qemu= =20=20=20=20=20=20 repeats libusb_get_config_descriptor() with incrementing config_index until= =20=20=20=20 the function returns an error. The specification of libusb_get_config_descriptor():=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 =20 http://libusb.sourceforge.net/api-1.0/group__libusb__desc.html#gaa635d9aec7= 7d\e4895dd0896ccf001532 The implementation in Linux: https://github.com/libusb/libusb/blob/v1.0.22/libusb/descriptor.c#L625 --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-238412-19105>