Skip to contentSkip to conversation

usb-host: add range checks for usb-host parameters

PATCH New Gerd Hoffmann 1 participant 1 message Dec 12, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb-host: add range checks for usb-host parameters

---
 hw/usb/host-libusb.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
hw/usb/host-libusb.c +13 -0
index fd320cd..164adf8 100644
@@ -898,6 +898,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;
Signature · 1 line
1.8.3.1