summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2021-01-05 15:04:31 +0100
committerPali Rohár <pali.rohar@gmail.com>2021-01-05 15:04:31 +0100
commit9bc4b8c26f2ae32a4cedb73c015ba5dad8bef032 (patch)
tree89b350edc03cf1b431a0b643499cf78a9f22b817
parente6422cf5a21f9bf578f02cb33d9b0b8e4130369b (diff)
download0xFFFF-9bc4b8c26f2ae32a4cedb73c015ba5dad8bef032.tar.bz2
usb-device: Check that usb device provides required interface/alternate settings
-rw-r--r--src/usb-device.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/usb-device.c b/src/usb-device.c
index 101d795..27d2809 100644
--- a/src/usb-device.c
+++ b/src/usb-device.c
@@ -165,6 +165,18 @@ static struct usb_device_info * usb_device_is_valid(struct usb_device * dev) {
if ( usb_devices[i].protocol == FLASH_UNKN )
continue;
+ if ( dev->descriptor.bNumConfigurations < 1 )
+ continue;
+
+ if ( usb_devices[i].interface != -1 ) {
+ if ( usb_devices[i].interface >= dev->config[0].bNumInterfaces )
+ continue;
+ if ( usb_devices[i].alternate != -1 ) {
+ if ( usb_devices[i].alternate >= dev->config[0].interface[usb_devices[i].interface].num_altsetting )
+ continue;
+ }
+ }
+
printf("\b\b ");
PRINTF_END();
PRINTF_ADD("Found ");