If the kernel size is too big, it overwrite the initrd image in memory without detecting the problem. Let't detect this error and exit gracefully.
Signed-off-by: Daniel Lezcano <daniel.lezc...@free.fr> --- hw/arm_boot.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/hw/arm_boot.c b/hw/arm_boot.c index 620550b..50ec717 100644 --- a/hw/arm_boot.c +++ b/hw/arm_boot.c @@ -247,6 +247,13 @@ void arm_load_kernel(CPUState *env, struct arm_boot_info *info) info->entry = entry; if (is_linux) { if (info->initrd_filename) { + + if (KERNEL_LOAD_ADDR + kernel_size >= INITRD_LOAD_ADDR) { + fprintf(stderr, "qemu: kernel is too big: %d Bytes\n", + kernel_size); + exit(1); + } + initrd_size = load_image_targphys(info->initrd_filename, info->loader_start + INITRD_LOAD_ADDR, -- 1.7.0.4