diff options
author | Chris Dickens <christopher.a.dickens@gmail.com> | 2020-01-28 10:24:14 -0800 |
---|---|---|
committer | Chris Dickens <christopher.a.dickens@gmail.com> | 2020-01-28 10:24:14 -0800 |
commit | ce95f656adcda701888c7414d2ab0f88f3f2c0ae (patch) | |
tree | 591afe226a036c8fc94eafed1bd8d75900fbfb91 /libusb | |
parent | f128429320de75d0cd184acbf91d8ae8181e16d0 (diff) | |
download | libusb-ce95f656adcda701888c7414d2ab0f88f3f2c0ae.tar.gz |
Windows: Fix reported length of synchronous control transfers
WinUSB control transfers that complete synchronously are incorrectly
having the actual transfer length set to the size of the transfer
buffer. If the control transfer is a read, the device may return less
data than the transfer buffer size. Fix this by reporting the actual
bytes transferred.
Closes #667
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Diffstat (limited to 'libusb')
-rw-r--r-- | libusb/os/windows_winusb.c | 6 | ||||
-rw-r--r-- | libusb/version_nano.h | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/libusb/os/windows_winusb.c b/libusb/os/windows_winusb.c index 136abb2..7cb17be 100644 --- a/libusb/os/windows_winusb.c +++ b/libusb/os/windows_winusb.c @@ -2472,7 +2472,7 @@ static int winusbx_submit_control_transfer(int sub_api, struct usbi_transfer *it struct winusb_transfer_priv *transfer_priv = usbi_transfer_get_os_priv(itransfer); struct winusb_device_handle_priv *handle_priv = _device_handle_priv(transfer->dev_handle); PWINUSB_SETUP_PACKET setup = (PWINUSB_SETUP_PACKET)transfer->buffer; - ULONG size; + ULONG size, transferred; HANDLE winusb_handle; OVERLAPPED *overlapped; int current_interface; @@ -2510,13 +2510,13 @@ static int winusbx_submit_control_transfer(int sub_api, struct usbi_transfer *it } windows_force_sync_completion(overlapped, 0); } else { - if (!WinUSBX[sub_api].ControlTransfer(winusb_handle, *setup, transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE, size, NULL, overlapped)) { + if (!WinUSBX[sub_api].ControlTransfer(winusb_handle, *setup, transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE, size, &transferred, overlapped)) { if (GetLastError() != ERROR_IO_PENDING) { usbi_warn(ctx, "ControlTransfer failed: %s", windows_error_str(0)); return LIBUSB_ERROR_IO; } } else { - windows_force_sync_completion(overlapped, size); + windows_force_sync_completion(overlapped, transferred); } } diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 9cef97f..18c8cb7 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 11451 +#define LIBUSB_NANO 11452 |