]> Zhao Yanbai Git Server - minix.git/commitdiff
Allow elf_unpack to withstand invalid ELF headers 18/2818/2
authorLionel Sambuc <lionel@minix3.org>
Mon, 8 Sep 2014 08:16:41 +0000 (10:16 +0200)
committerLionel Sambuc <lionel@minix3.org>
Mon, 8 Sep 2014 09:48:57 +0000 (11:48 +0200)
Change-Id: I10a0f3111176b9614b8531d6736e2e860eb95ce4

minix/lib/libexec/exec_elf.c

index f6d8d21cd125fc790a1fc2fe540c8c3599fb6dc8..fca784aeb15fb3c910e631288cecd65587d5a345 100644 (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)) {