libelf: Rearrange size test to prevent integer overflow

Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Ed Maste 2014-12-31 01:48:23 +00:00
parent d866a563d4
commit 47fc54d8b0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=276443

View file

@ -62,7 +62,7 @@ _libelf_load_section_headers(Elf *e, void *ehdr)
#define CHECK_EHDR(E,EH) do { \
if (fsz != (EH)->e_shentsize || \
shnum > SIZE_MAX / fsz || \
shoff + fsz * shnum > e->e_rawsize) { \
fsz * shnum > e->e_rawsize - shoff) { \
LIBELF_SET_ERROR(HEADER, 0); \
return (0); \
} \