Ticket #48 (closed defect: fixed)
Opened 3 years ago
Last modified 18 months ago
windows_usb.c - Incorrect Configuration Descriptor Assumption
| Reported by: | benjamin dobell | Owned by: | pbatard |
|---|---|---|---|
| Milestone: | Component: | libusb-1.0 | |
| Keywords: | windows_usb.c, libusb_config_descriptor | Cc: | |
| Blocked By: | Blocks: |
Description
// Sanity check. Ensures that indexes for our list of config desc is in the right order
if (i != (cd_data->bConfigurationValue-1))
{
usbi_warn(ctx, "program assertion failed - config descriptors are being read out of order");
continue;
}
The above is incorrect and should be removed from windows_usb.c as it is possible to install the libusb driver for a component device as well is its interfaces.
Change History
comment:1 Changed 3 years ago by timrprobocom
comment:2 Changed 3 years ago by pbatard
There are 2 issues at hand here:
- If your goal in removing this section is to install the WinUSB driver as the Windows composite parent driver, which is what I assume you mean by component device, then you won't be able to use the interfaces at all. This is a limitation of WinUSB (because the WinUsb_GetAssociatedInterface() call cannot be used in that fashion) and the main reason why you should not attempt to use WinUSB as the composite parent driver (usbccgp), but only for its composite interfaces.
- Removing the section alone is expected to crash libusb. Some extra code needs to be added, which we will start working on.
comment:3 Changed 3 years ago by pbatard
- Owner set to pbatard
- Status changed from new to accepted
comment:4 Changed 3 years ago by pbatard
- Resolution set to fixed
- Status changed from accepted to closed
Should be fixed in pbr294 (actual fix was very close to what Benjamin described)
Now, while WinUsb_GetAssociatedInterface() indeed works for composite parent devices unlike what we reported earlier, the actual limitation seems to be that WinUsb_QueryInterfaceSettings() only returns the interface settings from the first interface, no matter what interface handle it is being fed.
comment:5 Changed 3 years ago by stuge
- Resolution fixed deleted
- Status changed from closed to reopened
Please don't close until fixed in libusb.git.
comment:6 Changed 18 months ago by pbatard
- Resolution set to fixed
- Status changed from reopened to closed
The description of the issue is wrong, although the problem is quite real and the code should be deleted. Unlike interface numbers, configuration values are not required to be either sequential or contiguous. The bConfigurationValue byte is just a key, not an array index. It is quite legal for me to have three configurations, in order, with bConfigurationValue set to 99, 16 and 42.