Fix for reading the configuration descriptor in libusb. Catch invalid

configuration descriptor reads early on to avoid issues with devices
that don't check for a valid USB configuration read request.

Submitted by:	takahiro.kurosawa@gmail.com
PR:		238412
MFC after:	3 days
This commit is contained in:
Hans Petter Selasky 2019-06-08 09:34:02 +00:00
parent a9de4100e6
commit 08216d1854

View File

@ -955,6 +955,14 @@ libusb20_dev_alloc_config(struct libusb20_device *pdev, uint8_t configIndex)
uint8_t do_close;
int error;
/*
* Catch invalid configuration descriptor reads early on to
* avoid issues with devices that don't check for a valid USB
* configuration read request.
*/
if (configIndex >= pdev->ddesc.bNumConfigurations)
return (NULL);
if (!pdev->is_opened) {
error = libusb20_dev_open(pdev, 0);
if (error) {