diff mbox

[PULL,1/1] usb-host: add range checks for usb-host parameters

Message ID 1402659320-15964-2-git-send-email-kraxel@redhat.com
State New
Headers show

Commit Message

Gerd Hoffmann June 13, 2014, 11:35 a.m. UTC
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/host-libusb.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff mbox

Patch

diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index afbf156..33b5b9f 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -952,6 +952,19 @@  static int usb_host_initfn(USBDevice *udev)
 {
     USBHostDevice *s = USB_HOST_DEVICE(udev);
 
+    if (s->match.vendor_id > 0xffff) {
+        error_report("vendorid out of range");
+        return -1;
+    }
+    if (s->match.product_id > 0xffff) {
+        error_report("productid out of range");
+        return -1;
+    }
+    if (s->match.addr > 127) {
+        error_report("hostaddr out of range");
+        return -1;
+    }
+
     loglevel = s->loglevel;
     udev->flags |= (1 << USB_DEV_FLAG_IS_HOST);
     udev->auto_attach = 0;