From 18a1452ee83358a8cd3d3fca7fed112ea1afa30f Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Tue, 1 Nov 2016 18:27:12 -0700 Subject: [PATCH] Windows: Allow HID reports up to 1024 + report id HID reports can contain up to 1024 bytes. When using a report id the complete buffer will be 1025 bytes. Do not return an error if the user supplies a report id and a buffer of 1025 bytes size. Closes #222 Closes #226 Signed-off-by: Stefan Agner Signed-off-by: Chris Dickens --- libusb/os/windows_winusb.c | 4 +++- libusb/version_nano.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libusb/os/windows_winusb.c b/libusb/os/windows_winusb.c index 545c59b..bccedb9 100644 --- a/libusb/os/windows_winusb.c +++ b/libusb/os/windows_winusb.c @@ -3357,11 +3357,13 @@ static int _hid_set_report(struct hid_device_priv *dev, HANDLE hid_handle, int i { uint8_t *buf = NULL; DWORD ioctl_code, write_size = (DWORD)*size; + // If an id is reported, we must allow MAX_HID_REPORT_SIZE + 1 + size_t max_report_size = MAX_HID_REPORT_SIZE + (id ? 1 : 0); if (tp->hid_buffer != NULL) usbi_dbg("program assertion failed: hid_buffer is not NULL"); - if ((*size == 0) || (*size > MAX_HID_REPORT_SIZE)) { + if ((*size == 0) || (*size > max_report_size)) { usbi_dbg("invalid size (%u)", *size); return LIBUSB_ERROR_INVALID_PARAM; } diff --git a/libusb/version_nano.h b/libusb/version_nano.h index e9b13cf..e9dbf91 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 11191 +#define LIBUSB_NANO 11192