From: Lionel Sambuc Date: Mon, 8 Sep 2014 08:16:41 +0000 (+0200) Subject: Allow elf_unpack to withstand invalid ELF headers X-Git-Tag: v3.3.0~14 X-Git-Url: http://zhaoyanbai.com/repos/?a=commitdiff_plain;h=6f7ac603f2e041fded7be32f28f4c7e1ade691b3;p=minix.git Allow elf_unpack to withstand invalid ELF headers Change-Id: I10a0f3111176b9614b8531d6736e2e860eb95ce4 --- diff --git a/minix/lib/libexec/exec_elf.c b/minix/lib/libexec/exec_elf.c index f6d8d21cd..fca784aeb 100644 --- a/minix/lib/libexec/exec_elf.c +++ b/minix/lib/libexec/exec_elf.c @@ -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)) {