From patchwork Thu Jun 13 07:02:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 250998 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 DE4352C0099 for ; Thu, 13 Jun 2013 17:34:05 +1000 (EST) Received: from localhost ([::1]:39713 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Un1aL-0005R7-Ls for incoming@patchwork.ozlabs.org; Thu, 13 Jun 2013 03:04:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52477) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Un1YB-0002y6-3R for qemu-devel@nongnu.org; Thu, 13 Jun 2013 03:02:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Un1Y8-000331-DN for qemu-devel@nongnu.org; Thu, 13 Jun 2013 03:02:27 -0400 Received: from oxygen.pond.sub.org ([2a01:4f8:121:10e4::3]:39478) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Un1Y8-00032d-6B for qemu-devel@nongnu.org; Thu, 13 Jun 2013 03:02:24 -0400 Received: from blackfin.pond.sub.org (p5B32AA2B.dip0.t-ipconnect.de [91.50.170.43]) by oxygen.pond.sub.org (Postfix) with ESMTPA id 1DC51A4310; Thu, 13 Jun 2013 09:02:22 +0200 (CEST) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C7D18200BC; Thu, 13 Jun 2013 09:02:19 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 13 Jun 2013 09:02:19 +0200 Message-Id: <1371106939-6968-9-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1371106939-6968-1-git-send-email-armbru@redhat.com> References: <1371106939-6968-1-git-send-email-armbru@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a01:4f8:121:10e4::3 Cc: mtosatti@redhat.com, borntraeger@de.ibm.com, pbonzini@redhat.com, agraf@suse.de, stefano.stabellini@eu.citrix.com Subject: [Qemu-devel] [PATCH RFC 8/8] pc_sysfw: Fix ISA BIOS init for ridiculously big flash 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 pc_isa_bios_init() suffers integer overflow for flash larger than INT_MAX. Signed-off-by: Markus Armbruster --- hw/block/pc_sysfw.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/hw/block/pc_sysfw.c b/hw/block/pc_sysfw.c index 412d1b0..aebefc9 100644 --- a/hw/block/pc_sysfw.c +++ b/hw/block/pc_sysfw.c @@ -54,10 +54,7 @@ static void pc_isa_bios_init(MemoryRegion *rom_memory, flash_size = memory_region_size(flash_mem); /* map the last 128KB of the BIOS in ISA space */ - isa_bios_size = flash_size; - if (isa_bios_size > (128 * 1024)) { - isa_bios_size = 128 * 1024; - } + isa_bios_size = MIN(flash_size, 128 * 1024); isa_bios = g_malloc(sizeof(*isa_bios)); memory_region_init_ram(isa_bios, "isa-bios", isa_bios_size); vmstate_register_ram_global(isa_bios);