summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--libusb/libusb_version.h2
-rw-r--r--libusb/os/windows_usb.c17
3 files changed, 8 insertions, 13 deletions
diff --git a/configure.ac b/configure.ac
index e32bfcc..ba6e938 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,7 @@
m4_define(LIBUSB_MAJOR, [1])
m4_define(LIBUSB_MINOR, [0])
m4_define(LIBUSB_MICRO, [8])
-m4_define(LIBUSB_NANO, [10312])
+m4_define(LIBUSB_NANO, [10313])
AC_INIT([libusb], LIBUSB_MAJOR.LIBUSB_MINOR.LIBUSB_MICRO, [libusb-devel@lists.sourceforge.net], [libusb], [http://www.libusb.org/])
diff --git a/libusb/libusb_version.h b/libusb/libusb_version.h
index b3bee2b..151e963 100644
--- a/libusb/libusb_version.h
+++ b/libusb/libusb_version.h
@@ -24,6 +24,6 @@
#define LIBUSB_VERSION_MAJOR 1
#define LIBUSB_VERSION_MINOR 0
#define LIBUSB_VERSION_MICRO 8
-#define LIBUSB_VERSION_NANO 10312
+#define LIBUSB_VERSION_NANO 10313
#endif
diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c
index 8842ebf..dbea297 100644
--- a/libusb/os/windows_usb.c
+++ b/libusb/os/windows_usb.c
@@ -3237,11 +3237,6 @@ static int _hid_get_report(struct hid_device_priv* dev, HANDLE hid_handle, int i
return LIBUSB_ERROR_INVALID_PARAM;
}
- // When report IDs are not in use, add an extra byte for the report ID
- if (id==0) {
- expected_size++;
- }
-
// Add a trailing byte to detect overflows
buf = (uint8_t*)calloc(expected_size+1, 1);
if (buf == NULL) {
@@ -3251,7 +3246,9 @@ static int _hid_get_report(struct hid_device_priv* dev, HANDLE hid_handle, int i
usbi_dbg("report ID: 0x%02X", buf[0]);
tp->hid_expected_size = expected_size;
+ read_size = expected_size;
+ // NB: The size returned by DeviceIoControl doesn't include report IDs when not in use (0)
if (!DeviceIoControl(hid_handle, ioctl_code, buf, expected_size+1,
buf, expected_size+1, &read_size, overlapped)) {
if (GetLastError() != ERROR_IO_PENDING) {
@@ -3267,7 +3264,7 @@ static int _hid_get_report(struct hid_device_priv* dev, HANDLE hid_handle, int i
// Transfer completed synchronously => copy and discard extra buffer
if (read_size == 0) {
- usbi_dbg("program assertion failed - read completed synchronously, but no data was read");
+ usbi_warn(NULL, "program assertion failed - read completed synchronously, but no data was read");
*size = 0;
} else {
if (buf[0] != id) {
@@ -3280,12 +3277,11 @@ static int _hid_get_report(struct hid_device_priv* dev, HANDLE hid_handle, int i
r = LIBUSB_COMPLETED;
}
+ *size = MIN((size_t)read_size, *size);
if (id == 0) {
// Discard report ID
- *size = MIN((size_t)read_size-1, *size);
memcpy(data, buf+1, *size);
} else {
- *size = MIN((size_t)read_size, *size);
memcpy(data, buf, *size);
}
}
@@ -3343,6 +3339,7 @@ static int _hid_set_report(struct hid_device_priv* dev, HANDLE hid_handle, int i
}
}
+ // NB: The size returned by DeviceIoControl doesn't include report IDs when not in use (0)
if (!DeviceIoControl(hid_handle, ioctl_code, buf, write_size,
buf, write_size, &write_size, overlapped)) {
if (GetLastError() != ERROR_IO_PENDING) {
@@ -3356,11 +3353,9 @@ static int _hid_set_report(struct hid_device_priv* dev, HANDLE hid_handle, int i
}
// Transfer completed synchronously
+ *size = write_size;
if (write_size == 0) {
usbi_dbg("program assertion failed - write completed synchronously, but no data was written");
- *size = 0;
- } else {
- *size = write_size - ((id == 0)?1:0);
}
safe_free(buf);
return LIBUSB_COMPLETED;