windows_winusb: Bounds check interface for check_valid_interface
authorLéo Lam <leo@innovatetechnologi.es>
Fri, 3 May 2019 10:57:43 +0000 (12:57 +0200)
committerNathan Hjelm <hjelmn@me.com>
Mon, 8 Jul 2019 04:00:03 +0000 (22:00 -0600)
This prevents a nasty out-of-bounds read and a likely crash when
the interface number is invalid.

Closes #568

Signed-off-by: Nathan Hjelm <hjelmn@me.com>
libusb/os/windows_winusb.c
libusb/version_nano.h

index e18a723..c7aec1f 100644 (file)
@@ -2412,6 +2412,9 @@ static int get_valid_interface(struct libusb_device_handle *dev_handle, int api_
 */
 static int check_valid_interface(struct libusb_device_handle *dev_handle, unsigned short interface, int api_id)
 {
+       if (interface >= USB_MAXINTERFACES)
+               return -1;
+
        struct winusb_device_handle_priv *handle_priv = _device_handle_priv(dev_handle);
        struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
 
index 971eaf4..50676e4 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 11373
+#define LIBUSB_NANO 11374