Skip to content

Commit

Permalink
Allow reading HID descriptors larger than 255 bytes
Browse files Browse the repository at this point in the history
Fixes #114
  • Loading branch information
hughsie committed Nov 22, 2023
1 parent 860108f commit de7d8ee
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions gusb/gusb-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,7 @@ g_usb_device_get_hid_descriptor_for_interface(GUsbDevice *self, GUsbInterface *i
const guint8 *buf;
gsize actual_length = 0;
gsize buf2sz;
guint16 buf2szle = 0;
g_autofree guint8 *buf2 = NULL;

extra = g_usb_interface_get_extra(intf);
Expand Down Expand Up @@ -1373,15 +1374,16 @@ g_usb_device_get_hid_descriptor_for_interface(GUsbDevice *self, GUsbInterface *i
(guint)LIBUSB_DT_HID);
return NULL;
}
if (buf[7] == 0) {
memcpy(&buf2szle, buf + 7, sizeof(buf2szle));
buf2sz = GUINT16_FROM_LE(buf2szle);
if (buf2sz == 0) {
g_set_error(error,
G_IO_ERROR,
G_IO_ERROR_NOT_FOUND,
"missing data on HID interface 0x%x",
g_usb_interface_get_number(intf));
return NULL;
}
buf2sz = buf[7];
g_debug("get 0x%x bytes of HID descriptor", (guint)buf2sz);

/* get HID descriptor */
Expand Down

0 comments on commit de7d8ee

Please sign in to comment.