From d3d7a855b10cb8f95c933db46311ef70f3a43952 Mon Sep 17 00:00:00 2001 From: Tormod Volden Date: Wed, 28 Aug 2024 17:40:29 +0200 Subject: [PATCH] descriptor: Warn on invalid langid descriptor Closes #1548 Signed-off-by: Tormod Volden --- libusb/descriptor.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libusb/descriptor.c b/libusb/descriptor.c index 2ab1d47b1..e127800c6 100644 --- a/libusb/descriptor.c +++ b/libusb/descriptor.c @@ -1268,9 +1268,10 @@ int API_EXPORTED libusb_get_string_descriptor_ascii(libusb_device_handle *dev_ha r = libusb_get_string_descriptor(dev_handle, 0, 0, str.buf, 4); if (r < 0) return r; - else if (r != 4 || str.desc.bLength < 4 || str.desc.bDescriptorType != LIBUSB_DT_STRING) + else if (r != 4 || str.desc.bLength < 4 || str.desc.bDescriptorType != LIBUSB_DT_STRING) { + usbi_warn(HANDLE_CTX(dev_handle), "invalid language ID string descriptor"); return LIBUSB_ERROR_IO; - else if (str.desc.bLength & 1) + } else if (str.desc.bLength & 1) usbi_warn(HANDLE_CTX(dev_handle), "suspicious bLength %u for language ID string descriptor", str.desc.bLength); langid = libusb_le16_to_cpu(str.desc.wData[0]);