From 48e5f8fc7e76e9e7b93a316ce4532f3b48c6e687 Mon Sep 17 00:00:00 2001 From: pancake Date: Thu, 16 Jun 2016 22:18:10 +0200 Subject: [PATCH] Fix ELF crash (null deref when missing shdr --- libr/bin/format/elf/elf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libr/bin/format/elf/elf.c b/libr/bin/format/elf/elf.c index b55716e8d0..06597ea55e 100644 --- a/libr/bin/format/elf/elf.c +++ b/libr/bin/format/elf/elf.c @@ -1782,7 +1782,7 @@ RBinElfReloc* Elf_(r_bin_elf_get_relocs)(struct Elf_(r_bin_elf_obj_t) *bin) { eprintf ("Warning: malformed file, relocation entry #%u is partially beyond the end of section %u.\n", rel, i); } if (bin->ehdr.e_type == ET_REL) { - if (g_sections[i].info < bin->ehdr.e_shnum) { + if (g_sections[i].info < bin->ehdr.e_shnum && bin->shdr) { ret[rel].rva = bin->shdr[g_sections[i].info].sh_offset + ret[rel].offset; ret[rel].rva = Elf_(r_bin_elf_p2v) (bin, ret[rel].rva); } else {