mirror of
https://github.com/qemu/qemu.git
synced 2024-12-04 01:03:38 +08:00
q800: fix segfault with invalid MacROM
"qemu-system-m68k -M q800 -bios /dev/null" crashes with a segfault in q800_init(). This happens because the code doesn't check that rom_ptr() returned a non-NULL pointer . To avoid NULL pointer, don't allow 0 sized file and use bios_size with rom_ptr(). Resolves: https://gitlab.com/qemu-project/qemu/-/issues/756 Reported-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Message-Id: <20220107105049.961489-1-laurent@vivier.eu> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
This commit is contained in:
parent
214bdf8e71
commit
0969e00b39
@ -672,12 +672,13 @@ static void q800_init(MachineState *machine)
|
||||
|
||||
/* Remove qtest_enabled() check once firmware files are in the tree */
|
||||
if (!qtest_enabled()) {
|
||||
if (bios_size < 0 || bios_size > MACROM_SIZE) {
|
||||
if (bios_size <= 0 || bios_size > MACROM_SIZE) {
|
||||
error_report("could not load MacROM '%s'", bios_name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ptr = rom_ptr(MACROM_ADDR, MACROM_SIZE);
|
||||
ptr = rom_ptr(MACROM_ADDR, bios_size);
|
||||
assert(ptr != NULL);
|
||||
stl_phys(cs->as, 0, ldl_p(ptr)); /* reset initial SP */
|
||||
stl_phys(cs->as, 4,
|
||||
MACROM_ADDR + ldl_p(ptr + 4)); /* reset initial PC */
|
||||
|
Loading…
Reference in New Issue
Block a user