mirror of
https://github.com/RPCS3/libusb.git
synced 2026-01-31 01:25:19 +01:00
Windows: UsbDk: Implement get_config_descriptor_by_value()
This fixes a NULL pointer dereference when the user selects the UsbDk backend and subsequently calls libusb_get_config_descriptor_by_value(). Closes #395 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
This commit is contained in:
@@ -370,7 +370,25 @@ static int usbdk_get_config_descriptor(struct libusb_device *dev, uint8_t config
|
||||
return (int)size;
|
||||
}
|
||||
|
||||
static inline int usbdk_get_active_config_descriptor(struct libusb_device *dev, unsigned char *buffer, size_t len)
|
||||
static int usbdk_get_config_descriptor_by_value(struct libusb_device *dev, uint8_t bConfigurationValue,
|
||||
unsigned char **buffer)
|
||||
{
|
||||
struct usbdk_device_priv *priv = _usbdk_device_priv(dev);
|
||||
PUSB_CONFIGURATION_DESCRIPTOR config_header;
|
||||
uint8_t index;
|
||||
|
||||
for (index = 0; index < dev->num_configurations; index++) {
|
||||
config_header = priv->config_descriptors[index];
|
||||
if (config_header->bConfigurationValue == bConfigurationValue) {
|
||||
*buffer = (unsigned char *)priv->config_descriptors[index];
|
||||
return (int)config_header->wTotalLength;
|
||||
}
|
||||
}
|
||||
|
||||
return LIBUSB_ERROR_NOT_FOUND;
|
||||
}
|
||||
|
||||
static int usbdk_get_active_config_descriptor(struct libusb_device *dev, unsigned char *buffer, size_t len)
|
||||
{
|
||||
return usbdk_get_config_descriptor(dev, _usbdk_device_priv(dev)->active_configuration,
|
||||
buffer, len);
|
||||
@@ -794,7 +812,7 @@ const struct windows_backend usbdk_backend = {
|
||||
usbdk_get_device_descriptor,
|
||||
usbdk_get_active_config_descriptor,
|
||||
usbdk_get_config_descriptor,
|
||||
NULL,//usbdk_get_config_descriptor_by_value,
|
||||
usbdk_get_config_descriptor_by_value,
|
||||
usbdk_get_configuration,
|
||||
usbdk_set_configuration,
|
||||
usbdk_claim_interface,
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define LIBUSB_NANO 11300
|
||||
#define LIBUSB_NANO 11301
|
||||
|
||||
Reference in New Issue
Block a user