aboutsummaryrefslogtreecommitdiff
path: root/lib/libusb
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2019-06-08 09:34:02 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2019-06-08 09:34:02 +0000
commit08216d1854c71002858fd09977eef4828add63cc (patch)
tree7bcfb08d47fa62fe4bf071328e424d486fb2b84e /lib/libusb
parenta9de4100e61e27a19bae90503f7396212dceaa48 (diff)
downloadsrc-08216d1854c71002858fd09977eef4828add63cc.tar.gz
src-08216d1854c71002858fd09977eef4828add63cc.zip
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
Notes
Notes: svn path=/head/; revision=348797
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) {