GBA: Handle out-of-bounds I/O access
Jeffrey Pfau jeffrey@endrift.com
Fri, 08 May 2015 01:48:22 -0700
2 files changed,
9 insertions(+),
0 deletions(-)
M
CHANGES
→
CHANGES
@@ -46,6 +46,7 @@ - SDL: Fix boundary conditions for joystick adjustments
- Util: Fix a null-pointer issue when attempting to delete a key - SDL: Allocate properly sized input maps - ARM7: Handle writeback for PC in addressing modes 2 and 3 + - GBA: Handle out-of-bounds I/O access Misc: - Qt: Show multiplayer numbers in window title - Qt: Handle saving input settings better
M
src/gba/io.c
→
src/gba/io.c
@@ -489,6 +489,10 @@ // Some bad interrupt libraries will write to this
break; default: GBALog(gba, GBA_LOG_STUB, "Stub I/O register write: %03x", address); + if (address >= REG_MAX) { + GBALog(gba, GBA_LOG_GAME_ERROR, "Write to unused I/O register: %03X", address); + return; + } break; } }@@ -643,6 +647,10 @@ // Some bad interrupt libraries will read from this
break; default: GBALog(gba, GBA_LOG_STUB, "Stub I/O register read: %03x", address); + if (address >= REG_MAX) { + GBALog(gba, GBA_LOG_GAME_ERROR, "Read from unused I/O register: %03X", address); + return 0; // TODO: Reuse LOAD_BAD + } break; } return gba->memory.io[address >> 1];