Received: from eggs.gnu.org ([140.186.70.92]:56405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RV5Pa-0007Ip-Aj for qemu-devel@nongnu.org; Mon, 28 Nov 2011 12:54:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RV5PY-0004xP-EX for qemu-devel@nongnu.org; Mon, 28 Nov 2011 12:54:38 -0500 Received: from v220110690675601.yourvserver.net ([78.47.199.172]:52072) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RV5PY-0004wN-9t for qemu-devel@nongnu.org; Mon, 28 Nov 2011 12:54:36 -0500 Message-ID: <4ED3CA9D.4030202@weilnetz.de> Date: Mon, 28 Nov 2011 18:53:33 +0100 From: Stefan Weil MIME-Version: 1.0 References: <1321903504-24287-1-git-send-email-sw@weilnetz.de> In-Reply-To: <1321903504-24287-1-git-send-email-sw@weilnetz.de> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] pseries: Fix possible out-of-bounds error List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf Cc: Anthony Liguori , qemu-devel@nongnu.org, David Gibson Am 21.11.2011 20:25, schrieb Stefan Weil: > PCI_NUM_REGIONS is 7, ARRAY_SIZE(bars) is 6. Either bars must be > extended by a 7th array element, or the loop which reads bars[i] > must terminate before it tries to read bars[6]. > > For dev->io_regions[6].size == 0, the old code also works, > but it is not obvious whether this is always true. > > This bug was detected by cppcheck. > > Cc: David Gibson > Signed-off-by: Stefan Weil > --- > hw/spapr_pci.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/hw/spapr_pci.c b/hw/spapr_pci.c > index 7162588..cefde38 100644 > --- a/hw/spapr_pci.c > +++ b/hw/spapr_pci.c > @@ -454,7 +454,7 @@ int spapr_populate_pci_devices(sPAPRPHBState *phb, > reg[0].size = 0; > > n = 0; > - for (i = 0; i< PCI_NUM_REGIONS; ++i) { > + for (i = 0; i< PCI_NUM_REGIONS&& i< ARRAY_SIZE(bars); ++i) { > if (0 == dev->io_regions[i].size) { > continue; > } > Ping? Can this be fixed in QEMU 1.0?