From e90ddd3c4222e68051fadea3d76426881af900fb Mon Sep 17 00:00:00 2001 From: Mateusz Moscicki Date: Fri, 11 Jun 2021 12:39:29 +0200 Subject: [PATCH] telf: Fix uninitialized pointer read Change-Id: I8bf8dbed9af82c895ec3040eeafdb03a0d74fd04 --- src/crash-stack/unwind.c | 4 ++++ src/shared/telf.c | 1 + 2 files changed, 5 insertions(+) diff --git a/src/crash-stack/unwind.c b/src/crash-stack/unwind.c index 44bff5d..3a2b455 100644 --- a/src/crash-stack/unwind.c +++ b/src/crash-stack/unwind.c @@ -79,6 +79,10 @@ static FILE *debug; static Elf *elf_start(int fd, char *image, uint64_t size) { Elf *elf = malloc(sizeof(Elf)); + if (elf == NULL) { + _E("Out of memory"); + return NULL; + } if (fd > 0) { if (!teu_begin(fd, elf)) diff --git a/src/shared/telf.c b/src/shared/telf.c index 09508c1..87b5209 100644 --- a/src/shared/telf.c +++ b/src/shared/telf.c @@ -174,6 +174,7 @@ bool teu_begin_memory(void *memory, Elf *elf) assert(elf); elf->status = TEU_MEMORY; + elf->data = memory; if (!teu_init(elf)) return false; -- 2.7.4