Skip to contentSkip to conversation

Check for invalid initrd file

PATCH New M. Mohan Kumar 1 participant 1 message Apr 12, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 hw/pc.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
hw/pc.c +6 -0
index ba14df0..99649ba 100644
@@ -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);
Signature · 1 line
1.6.6.1