From d6fa4b77fb8f27ac84cf23fb1e15016673d98a47 Mon Sep 17 00:00:00 2001 From: "M. Mohan Kumar" Date: Mon, 12 Apr 2010 10:01:33 +0530 Subject: [PATCH] Check for invalid initrd file 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 Signed-off-by: Aurelien Jarno --- hw/pc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/pc.c b/hw/pc.c index 69e597f3e2..b797f218f7 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -658,6 +658,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);