all repos — mgba @ 870c375cf61ddf416c88141d9d7bc9a63acf4d99

mGBA Game Boy Advance Emulator

Test: Fix crash when fuzzing fails to load a file
Vicki Pfau vi@endrift.com
Mon, 24 Apr 2017 13:35:28 -0700
commit

870c375cf61ddf416c88141d9d7bc9a63acf4d99

parent

422c3a25b887ef357e992d725a7e9d06fbfd5713

2 files changed, 9 insertions(+), 2 deletions(-)

jump to
M CHANGESCHANGES

@@ -47,6 +47,7 @@ - Qt: Ensure CLI backend is attached when submitting commands (fixes mgba.io/i/662)

- Core: Fix crash with rewind if savestates shrink - Test: Fix crash when loading invalid file - GBA Hardware: Fix crash if a savestate lies about game hardware + - Test: Fix crash when fuzzing fails to load a file Misc: - SDL: Remove scancode key input - GBA Video: Clean up unused timers
M src/platform/test/fuzz-main.csrc/platform/test/fuzz-main.c

@@ -94,10 +94,15 @@

#ifdef __AFL_HAVE_MANUAL_CONTROL __AFL_INIT(); #endif + + bool cleanExit = true; + if (!mCoreLoadFile(core, args.fname)) { + cleanExit = false; + goto loadError; + } if (args.patch) { core->loadPatch(core, VFileOpen(args.patch, O_RDONLY)); } - mCoreLoadFile(core, args.fname); struct VFile* savestate = 0; struct VFile* savestateOverlay = 0;

@@ -158,13 +163,14 @@ if (savestateOverlay) {

savestateOverlay->close(savestateOverlay); } +loadError: freeArguments(&args); if (outputBuffer) { free(outputBuffer); } core->deinit(core); - return 0; + return !cleanExit; } static void _fuzzRunloop(struct mCore* core, int frames) {