dfu: check iProduct and iInterface -> set to a default string when empty

This commit is contained in:
Gwenhael Goavec-Merou 2022-06-14 23:09:38 +02:00
parent 2e9fc1f4e9
commit 4d69675041
1 changed files with 7 additions and 0 deletions

View File

@ -366,10 +366,17 @@ int DFU::searchIfDFU(struct libusb_device_handle *handle,
my_dev.device = libusb_get_device_address(dev);
my_dev.bMaxPacketSize0 = desc->bMaxPacketSize0;
memset(my_dev.iProduct, 0, 128);
libusb_get_string_descriptor_ascii(handle, desc->iProduct,
my_dev.iProduct, 128);
if (strlen((char *)my_dev.iProduct) == 0)
snprintf((char *)my_dev.iProduct, 128, "empty");
memset(my_dev.iInterface, 0, 128);
libusb_get_string_descriptor_ascii(handle, intf->iInterface,
my_dev.iInterface, 128);
if (strlen((char *)my_dev.iInterface) == 0)
snprintf((char *)my_dev.iInterface, 128, "empty");
int r = libusb_get_port_numbers(dev, my_dev.path, sizeof(my_dev.path));
my_dev.path[r] = '\0';