all repos — mgba @ f7749b31de8611caa04c1fe1f281fc37a9e758b5

mGBA Game Boy Advance Emulator

Core: Fix loading ELF files that have unexpected empty program headers
Vicki Pfau vi@endrift.com
Tue, 24 Nov 2020 01:37:54 -0800
commit

f7749b31de8611caa04c1fe1f281fc37a9e758b5

parent

6ca62fae8324536a6748f6d576ae7ce671a6b400

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

jump to
M CHANGESCHANGES

@@ -56,6 +56,7 @@ - CMake: Fix build with downstream minizip that exports incompatible symbols

- CMake: Link with correct OpenGL library (fixes mgba.io/i/1872) - Core: Ensure ELF regions can be written before trying - Core: Fix threading improperly setting paused state while interrupted + - Core: Fix loading ELF files that have unexpected empty program headers - Debugger: Don't skip undefined instructions when debugger attached - Debugger: Close trace log when done tracing - Debugger: Fix change watchpoints (fixes mgba.io/i/1947)
M src/core/core.csrc/core/core.c

@@ -382,6 +382,9 @@ size_t i;

for (i = 0; i < ELFProgramHeadersSize(&ph); ++i) { size_t bsize, esize; Elf32_Phdr* phdr = ELFProgramHeadersGetPointer(&ph, i); + if (!phdr->p_filesz) { + continue; + } void* block = mCoreGetMemoryBlockMasked(core, phdr->p_paddr, &bsize, mCORE_MEMORY_WRITE | mCORE_MEMORY_WORM); char* bytes = ELFBytes(elf, &esize); if (block && bsize >= phdr->p_filesz && esize > phdr->p_offset && esize >= phdr->p_filesz + phdr->p_offset) {