summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorM. Mohan Kumar <mohan@in.ibm.com>2010-04-12 10:01:33 +0530
committerAurelien Jarno <aurelien@aurel32.net>2010-04-19 00:07:10 +0200
commitd6fa4b77fb8f27ac84cf23fb1e15016673d98a47 (patch)
tree9194966201291d7ec13faaf124c8b9ee942700f3
parentf1dc58e07decfa21f6141d6c441008d4b8b83331 (diff)
downloadqemu-d6fa4b77fb8f27ac84cf23fb1e15016673d98a47.tar.gz
qemu-d6fa4b77fb8f27ac84cf23fb1e15016673d98a47.tar.bz2
qemu-d6fa4b77fb8f27ac84cf23fb1e15016673d98a47.zip
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 <mohan@in.ibm.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
-rw-r--r--hw/pc.c6
1 files changed, 6 insertions, 0 deletions
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);