qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] Check for invalid initrd file


From: M. Mohan Kumar
Subject: [Qemu-devel] [PATCH] Check for invalid initrd file
Date: Mon, 12 Apr 2010 10:01:33 +0530

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 <address@hidden>
---
 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);
-- 
1.6.6.1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]