Windows: UsbDk: Fix potential buffer overflow
authorChris Dickens <christopher.a.dickens@gmail.com>
Mon, 12 Mar 2018 17:25:02 +0000 (10:25 -0700)
committerChris Dickens <christopher.a.dickens@gmail.com>
Mon, 12 Mar 2018 17:25:02 +0000 (10:25 -0700)
Closes #397

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
libusb/os/windows_usbdk.c
libusb/version_nano.h

index 1355000..fbccbd5 100644 (file)
@@ -204,9 +204,9 @@ static void usbdk_exit(struct libusb_context *ctx)
 static int usbdk_get_session_id_for_device(struct libusb_context *ctx,
        PUSB_DK_DEVICE_ID id, unsigned long *session_id)
 {
-       char dev_identity[ARRAYSIZE(id->DeviceID) + ARRAYSIZE(id->InstanceID)];
+       char dev_identity[ARRAYSIZE(id->DeviceID) + ARRAYSIZE(id->InstanceID) + 1];
 
-       if (sprintf(dev_identity, "%S%S", id->DeviceID, id->InstanceID) == -1) {
+       if (snprintf(dev_identity, sizeof(dev_identity), "%S%S", id->DeviceID, id->InstanceID) == -1) {
                usbi_warn(ctx, "cannot form device identity", id->DeviceID);
                return LIBUSB_ERROR_NOT_SUPPORTED;
        }
index 5b295ba..1adf635 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 11304
+#define LIBUSB_NANO 11305