Skip to content

Commit

Permalink
descriptor: Warn on invalid langid descriptor
Browse files Browse the repository at this point in the history
Closes libusb#1548

Signed-off-by: Tormod Volden <[email protected]>
  • Loading branch information
tormodvolden committed Aug 28, 2024
1 parent 467b6a8 commit d3d7a85
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions libusb/descriptor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down

0 comments on commit d3d7a85

Please sign in to comment.