From 40a29037dfe663a81f63dd451868575622ca29a9 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Fri, 3 Jul 2020 13:33:08 +0200 Subject: [PATCH] Reverted check for short usb descriptor (cherry picked from commit 6ba67a07beeb44878912851cf6ed6c6bf7443e09) --- channels/urbdrc/client/libusb/libusb_udevice.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/channels/urbdrc/client/libusb/libusb_udevice.c b/channels/urbdrc/client/libusb/libusb_udevice.c index ce231ba..7072d9d 100644 --- a/channels/urbdrc/client/libusb/libusb_udevice.c +++ b/channels/urbdrc/client/libusb/libusb_udevice.c @@ -762,7 +762,7 @@ static UINT32 libusb_udev_control_query_device_text(IUDEVICE* idev, UINT32 TextT { UDEVICE* pdev = (UDEVICE*)idev; LIBUSB_DEVICE_DESCRIPTOR* devDescriptor; - const char* strDesc = "Generic Usb String"; + const char strDesc[] = "Generic Usb String"; char deviceLocation[25] = { 0 }; BYTE bus_number; BYTE device_address; @@ -795,7 +795,7 @@ static UINT32 libusb_udev_control_query_device_text(IUDEVICE* idev, UINT32 TextT slen = data[0]; locale = data[1]; - if ((ret <= 0) || (ret < 4) || (slen < 4) || (locale != LIBUSB_DT_STRING) || + if ((ret <= 0) || (ret <= 4) || (slen <= 4) || (locale != LIBUSB_DT_STRING) || (ret > UINT8_MAX)) { WLog_Print(urbdrc->log, WLOG_DEBUG, @@ -803,7 +803,7 @@ static UINT32 libusb_udev_control_query_device_text(IUDEVICE* idev, UINT32 TextT "ERROR num %d, iProduct: %" PRIu8 "!", ret, devDescriptor->iProduct); - len = MIN(sizeof(strDesc), inSize); + len = strnlen(strDesc, MIN(sizeof(strDesc), inSize)); for (i = 0; i < len; i++) text[i] = (WCHAR)strDesc[i]; -- 2.7.4