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

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Gerd Hoffmann 2013-12-12 14:47:15 +01:00
parent 2a2c4830c0
commit f3cda6e060
1 changed files with 13 additions and 0 deletions

View File

@ -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;