From 4d6967504109c1d6a85f2426c174fe381e5dc890 Mon Sep 17 00:00:00 2001 From: Gwenhael Goavec-Merou Date: Tue, 14 Jun 2022 23:09:38 +0200 Subject: [PATCH] dfu: check iProduct and iInterface -> set to a default string when empty --- src/dfu.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/dfu.cpp b/src/dfu.cpp index 90e0b06..0c975c0 100644 --- a/src/dfu.cpp +++ b/src/dfu.cpp @@ -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';