aboutsummaryrefslogtreecommitdiff
path: root/lib/libusb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libusb')
-rw-r--r--lib/libusb/libusb20.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/libusb/libusb20.c b/lib/libusb/libusb20.c
index 05094443c10b..255e7d5ed516 100644
--- a/lib/libusb/libusb20.c
+++ b/lib/libusb/libusb20.c
@@ -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) {