Allow elf_unpack to withstand invalid ELF headers

Change-Id: I10a0f3111176b9614b8531d6736e2e860eb95ce4
This commit is contained in:
Lionel Sambuc 2014-09-08 10:16:41 +02:00
parent ea36b58e62
commit 6f7ac603f2

View file

@ -58,7 +58,8 @@ static int elf_ph_sane(Elf_Phdr *phdr)
static int elf_unpack(char *exec_hdr,
int hdr_len, Elf_Ehdr **hdr, Elf_Phdr **phdr)
{
assert(hdr_len >= sizeof(Elf_Ehdr));
if(hdr_len < sizeof(Elf_Ehdr))
return ENOEXEC;
*hdr = (Elf_Ehdr *) exec_hdr;
if(!elf_sane(*hdr)) {