summaryrefslogtreecommitdiffstats
path: root/contrib/elftoolchain
diff options
context:
space:
mode:
authoremaste <emaste@FreeBSD.org>2015-01-16 15:16:19 +0000
committeremaste <emaste@FreeBSD.org>2015-01-16 15:16:19 +0000
commit10cd749e1511b75822667f5153ea7aec74193b9f (patch)
tree3bb845f27ad2e16d5aeaaf139777a38bc59c3be9 /contrib/elftoolchain
parentd8422ac82c56192ee2879a1c0c6697be7640d46a (diff)
downloadFreeBSD-src-10cd749e1511b75822667f5153ea7aec74193b9f.zip
FreeBSD-src-10cd749e1511b75822667f5153ea7aec74193b9f.tar.gz
Verify that section header offset is not past EOF
MFC After: 1 week Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'contrib/elftoolchain')
-rw-r--r--contrib/elftoolchain/libelf/elf_scn.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/contrib/elftoolchain/libelf/elf_scn.c b/contrib/elftoolchain/libelf/elf_scn.c
index 209e2ef..9a9c816 100644
--- a/contrib/elftoolchain/libelf/elf_scn.c
+++ b/contrib/elftoolchain/libelf/elf_scn.c
@@ -60,7 +60,8 @@ _libelf_load_section_headers(Elf *e, void *ehdr)
assert((e->e_flags & LIBELF_F_SHDRS_LOADED) == 0);
#define CHECK_EHDR(E,EH) do { \
- if (fsz != (EH)->e_shentsize || \
+ if (shoff > e->e_rawsize || \
+ fsz != (EH)->e_shentsize || \
shnum > SIZE_MAX / fsz || \
fsz * shnum > e->e_rawsize - shoff) { \
LIBELF_SET_ERROR(HEADER, 0); \
OpenPOWER on IntegriCloud