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>
master
M. Mohan Kumar 2010-04-12 10:01:33 +05:30 committed by Aurelien Jarno
parent f1dc58e07d
commit d6fa4b77fb
1 changed files with 6 additions and 0 deletions

View File

@ -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);