From patchwork Mon Apr 12 04:31:33 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohan Kumar M X-Patchwork-Id: 49939 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 42172B7D1B for ; Mon, 12 Apr 2010 14:34:51 +1000 (EST) Received: from localhost ([127.0.0.1]:47882 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O1BJj-0003Wt-Uu for incoming@patchwork.ozlabs.org; Mon, 12 Apr 2010 00:32:11 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O1BJI-0003WV-Sh for qemu-devel@nongnu.org; Mon, 12 Apr 2010 00:31:44 -0400 Received: from [140.186.70.92] (port=55888 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O1BJH-0003W3-KY for qemu-devel@nongnu.org; Mon, 12 Apr 2010 00:31:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O1BJF-0004SE-RZ for qemu-devel@nongnu.org; Mon, 12 Apr 2010 00:31:43 -0400 Received: from e28smtp04.in.ibm.com ([122.248.162.4]:38143) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O1BJF-0004Rl-4m for qemu-devel@nongnu.org; Mon, 12 Apr 2010 00:31:41 -0400 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by e28smtp04.in.ibm.com (8.14.3/8.13.1) with ESMTP id o3C4VXRN019692 for ; Mon, 12 Apr 2010 10:01:33 +0530 Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o3C4VXrZ3387588 for ; Mon, 12 Apr 2010 10:01:33 +0530 Received: from d28av03.in.ibm.com (loopback [127.0.0.1]) by d28av03.in.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id o3C4VXLb010161 for ; Mon, 12 Apr 2010 14:31:33 +1000 Received: from localhost.localdomain ([9.124.35.44]) by d28av03.in.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id o3C4VXcd010158; Mon, 12 Apr 2010 14:31:33 +1000 From: "M. Mohan Kumar" To: qemu-devel@nongnu.org, jvrao Date: Mon, 12 Apr 2010 10:01:33 +0530 Message-Id: <1271046693-6240-1-git-send-email-mohan@in.ibm.com> X-Mailer: git-send-email 1.6.6.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: Subject: [Qemu-devel] [PATCH] Check for invalid initrd file X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org When qemu is invoked with an invalid initrd file, it crashes. Following patch prints a error message and exits if an invalid initrd is specified. Includes changes suggested by JV. Signed-off-by: M. Mohan Kumar --- hw/pc.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/hw/pc.c b/hw/pc.c index ba14df0..99649ba 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -657,6 +657,12 @@ static void load_linux(void *fw_cfg, } initrd_size = get_image_size(initrd_filename); + if (initrd_size < 0) { + fprintf(stderr, "qemu: error reading initrd %s\n", + initrd_filename); + exit(1); + } + initrd_addr = (initrd_max-initrd_size) & ~4095; initrd_data = qemu_malloc(initrd_size);