[PATCH v6 4/8] common: elf: check number of elf program headers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



An elf file without program headers should not be loaded. Add a check
for such cases.

Signed-off-by: Clement Leger <cleger@xxxxxxxxx>
---
 common/elf.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/common/elf.c b/common/elf.c
index 0e92661e1..bd97858c8 100644
--- a/common/elf.c
+++ b/common/elf.c
@@ -119,6 +119,11 @@ static int elf_check_image(struct elf_image *elf)
 		return -ENOEXEC;
 	}
 
+	if (!elf_hdr_e_phnum(elf, elf->buf)) {
+		pr_err("No phdr found.\n");
+		return -ENOEXEC;
+	}
+
 	return 0;
 }
 
-- 
2.17.1


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux