Verify that section header offset is not past EOF

MFC After:	1 week
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Ed Maste 2015-01-16 15:16:19 +00:00
parent 1b922b707e
commit 8ae6c16d82

View File

@ -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); \