From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=59819 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PFkeS-00006z-9M for qemu-devel@nongnu.org; Tue, 09 Nov 2010 04:38:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PFkXZ-0000Y3-US for qemu-devel@nongnu.org; Tue, 09 Nov 2010 04:32:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:3098) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PFkXZ-0000Xm-MK for qemu-devel@nongnu.org; Tue, 09 Nov 2010 04:30:57 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oA99Uuxn011409 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 9 Nov 2010 04:30:56 -0500 From: Markus Armbruster Subject: Re: [Qemu-devel] [PATCH] Out off array access in usb-net References: <20101109073653.GF9036@redhat.com> Date: Tue, 09 Nov 2010 10:30:54 +0100 In-Reply-To: <20101109073653.GF9036@redhat.com> (Gleb Natapov's message of "Tue, 9 Nov 2010 09:36:53 +0200") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gleb Natapov Cc: qemu-devel@nongnu.org Gleb Natapov writes: > Properly check array bounds before accessing array element. Impact? Apply to stable as well? > Signed-off-by: Gleb Natapov > diff --git a/hw/usb-net.c b/hw/usb-net.c > index 70f9263..84e2d79 100644 > --- a/hw/usb-net.c > +++ b/hw/usb-net.c > @@ -1142,7 +1142,7 @@ static int usb_net_handle_control(USBDevice *dev, int request, int value, > break; > > default: > - if (usb_net_stringtable[value & 0xff]) { > + if (ARRAY_SIZE(usb_net_stringtable) > (value & 0xff)) { > ret = set_usb_string(data, > usb_net_stringtable[value & 0xff]); > break; Makes sense. Nitpick: LIMIT > INDEX looks unusual to me; INDEX < LIMIT is more common.