all repos — mgba @ 32885140c89dcf03f46cad18ce99f4775de6d2f6

mGBA Game Boy Advance Emulator

Util: Fix crash reading invalid ELFs
Vicki Pfau vi@endrift.com
Fri, 31 Jan 2020 18:03:48 -0800
commit

32885140c89dcf03f46cad18ce99f4775de6d2f6

parent

d98e30f984e6bdcec1581783bddb744f3c4f8a14

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

jump to
M CHANGESCHANGES

@@ -15,6 +15,7 @@ - Qt: Fix missing OSD messages

- Qt: Fix crash unloading shaders - Qt: Fix toggled actions on gamepads (fixes mgba.io/i/1650) - Qt: Fix extraneous dialog (fixes mgba.io/i/1654) + - Util: Fix crash reading invalid ELFs 0.8.0: (2020-01-21) Features:
M src/util/elf-read.csrc/util/elf-read.c

@@ -84,6 +84,9 @@ void ELFGetProgramHeaders(struct ELF* elf, struct ELFProgramHeaders* ph) {

ELFProgramHeadersClear(ph); Elf32_Ehdr* hdr = elf32_getehdr(elf->e); Elf32_Phdr* phdr = elf32_getphdr(elf->e); + if (!hdr || !phdr) { + return; + } ELFProgramHeadersResize(ph, hdr->e_phnum); memcpy(ELFProgramHeadersGetPointer(ph, 0), phdr, sizeof(*phdr) * hdr->e_phnum); }