all repos — mgba @ 78db3e1a7491be7ead2e583c4258aad2b97d0295

mGBA Game Boy Advance Emulator

GBA: Handle out-of-bounds I/O access
Jeffrey Pfau jeffrey@endrift.com
Fri, 08 May 2015 01:48:22 -0700
commit

78db3e1a7491be7ead2e583c4258aad2b97d0295

parent

ebcb344d647dc767b6ef50fb2ba2d3812d248441

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

jump to
M CHANGESCHANGES

@@ -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.csrc/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];