Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow reading HID descriptors larger than 255 bytes #115

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 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,16 +1374,19 @@ 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);
g_debug("get 0x%x bytes of HID descriptor on iface 0x%x",
(guint)buf2sz,
g_usb_interface_get_number(intf));

/* get HID descriptor */
buf2 = g_malloc0(buf2sz);
Expand Down