From patchwork Thu May 3 14:27:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Borntraeger X-Patchwork-Id: 156705 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 76091B6EEB for ; Fri, 4 May 2012 00:28:29 +1000 (EST) Received: from localhost ([::1]:46126 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPx19-0005u6-A2 for incoming@patchwork.ozlabs.org; Thu, 03 May 2012 10:28:27 -0400 Received: from eggs.gnu.org ([208.118.235.92]:41082) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPx0y-0005ta-FC for qemu-devel@nongnu.org; Thu, 03 May 2012 10:28:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SPx0o-0000uP-Hq for qemu-devel@nongnu.org; Thu, 03 May 2012 10:28:16 -0400 Received: from e06smtp14.uk.ibm.com ([195.75.94.110]:47442) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPx0o-0000u6-6u for qemu-devel@nongnu.org; Thu, 03 May 2012 10:28:06 -0400 Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 3 May 2012 15:28:03 +0100 Received: from d06nrmr1507.portsmouth.uk.ibm.com (9.149.38.233) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 3 May 2012 15:28:00 +0100 Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by d06nrmr1507.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q43ES0dx2662560 for ; Thu, 3 May 2012 15:28:00 +0100 Received: from d06av02.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q43ERwNW009595 for ; Thu, 3 May 2012 08:27:59 -0600 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q43ERwQJ009588; Thu, 3 May 2012 08:27:58 -0600 Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id B2F3512243A7; Thu, 3 May 2012 16:27:58 +0200 (CEST) From: Christian Borntraeger To: agraf@suse.de Date: Thu, 3 May 2012 16:27:57 +0200 Message-Id: <1336055277-53204-1-git-send-email-borntraeger@de.ibm.com> X-Mailer: git-send-email 1.7.9.6 In-Reply-To: <4EC02384-64EF-4514-975C-A3D229B3693E@suse.de> References: <4EC02384-64EF-4514-975C-A3D229B3693E@suse.de> x-cbid: 12050314-1948-0000-0000-000001B22BD1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 195.75.94.110 Cc: qemu-devel@nongnu.org, Christian Borntraeger , peter.maydell@linaro.org Subject: [Qemu-devel] [PATCH] Fix size checking in load_image_targphys to accept max_size > INT_MAX 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 commit 17df768c1e4580f03301d18ea938d3557d441911 load_image_targphys() should enforce the max size caused some problems with external kernel and specific ram sizes on s390: We load the external kernel with [...] kernel_size = load_image_targphys(kernel_filename, 0, ram_size); [...] Since load_image_targphys is declared as taking an int for max_sz, this will fail for ram sizes > INT_MAX. Lets change the max_sz parameter to a uint64_t. Signed-off-by: Christian Borntraeger --- hw/loader.c | 2 +- hw/loader.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/loader.c b/hw/loader.c index 415cdce..7d64113 100644 --- a/hw/loader.c +++ b/hw/loader.c @@ -103,7 +103,7 @@ ssize_t read_targphys(const char *name, /* return the size or -1 if error */ int load_image_targphys(const char *filename, - target_phys_addr_t addr, int max_sz) + target_phys_addr_t addr, uint64_t max_sz) { int size; diff --git a/hw/loader.h b/hw/loader.h index fbcaba9..5cfa6df 100644 --- a/hw/loader.h +++ b/hw/loader.h @@ -4,7 +4,7 @@ /* loader.c */ int get_image_size(const char *filename); int load_image(const char *filename, uint8_t *addr); /* deprecated */ -int load_image_targphys(const char *filename, target_phys_addr_t, int max_sz); +int load_image_targphys(const char *filename, target_phys_addr_t, uint64_t); int load_elf(const char *filename, uint64_t (*translate_fn)(void *, uint64_t), void *translate_opaque, uint64_t *pentry, uint64_t *lowaddr, uint64_t *highaddr, int big_endian, int elf_machine,