From patchwork Thu Dec 12 13:47:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 300664 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BC7EE2C00A4 for ; Fri, 13 Dec 2013 00:48:15 +1100 (EST) Received: from localhost ([::1]:36664 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vr6cf-0004Nw-A8 for incoming@patchwork.ozlabs.org; Thu, 12 Dec 2013 08:48:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34677) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vr6c6-0004GG-15 for qemu-devel@nongnu.org; Thu, 12 Dec 2013 08:47:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vr6bz-0002N4-Ur for qemu-devel@nongnu.org; Thu, 12 Dec 2013 08:47:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:25034) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vr6bz-0002Mx-NK for qemu-devel@nongnu.org; Thu, 12 Dec 2013 08:47:31 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rBCDlTOm022132 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 12 Dec 2013 08:47:30 -0500 Received: from nilsson.home.kraxel.org (vpn1-5-39.ams2.redhat.com [10.36.5.39]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id rBCDlTOg001855; Thu, 12 Dec 2013 08:47:29 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 8F345808BB; Thu, 12 Dec 2013 14:47:28 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 12 Dec 2013 14:47:26 +0100 Message-Id: <1386856046-28929-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH] usb-host: add range checks for usb-host parameters X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Gerd Hoffmann --- hw/usb/host-libusb.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c index fd320cd..164adf8 100644 --- a/hw/usb/host-libusb.c +++ b/hw/usb/host-libusb.c @@ -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;