diff options
author | Pali Rohár <pali.rohar@gmail.com> | 2021-01-05 15:04:31 +0100 |
---|---|---|
committer | Pali Rohár <pali.rohar@gmail.com> | 2021-01-05 15:04:31 +0100 |
commit | 9bc4b8c26f2ae32a4cedb73c015ba5dad8bef032 (patch) | |
tree | 89b350edc03cf1b431a0b643499cf78a9f22b817 | |
parent | e6422cf5a21f9bf578f02cb33d9b0b8e4130369b (diff) | |
download | 0xFFFF-9bc4b8c26f2ae32a4cedb73c015ba5dad8bef032.tar.bz2 |
usb-device: Check that usb device provides required interface/alternate settings
-rw-r--r-- | src/usb-device.c | 12 |
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 "); |