Commit 870b4be96f80a9b107fd90779ad715a57876a23e

Con Kolivas 2014-02-22T15:52:15

Transferred value is corrupt on a NODEV error in usbutils.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/usbutils.c b/usbutils.c
index 630a963..316e31e 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -2747,7 +2747,9 @@ err_retry:
 	}
 	if (err == LIBUSB_ERROR_IO && ++err_retries < USB_RETRY_MAX)
 		goto err_retry;
-	if (!NODEV(err) && (endpoint & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_IN)
+	if (NODEV(err))
+		*transferred = 0;
+	else if ((endpoint & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_IN)
 		memcpy(data, buf, *transferred);
 
 	return err;