summaryrefslogtreecommitdiff
path: root/libelf/elf_scn.c
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2019-06-29 15:27:18 +0000
committerEd Maste <emaste@FreeBSD.org>2019-06-29 15:27:18 +0000
commita5b08c1484eac2c6a65e726f550b3189ff84c6c8 (patch)
tree01cd9d6d76e2c378b391422460c6f233ead08179 /libelf/elf_scn.c
parent2b92b30119ed91ed88f102ba9ecc40cd1c046a65 (diff)
Notes
Diffstat (limited to 'libelf/elf_scn.c')
-rw-r--r--libelf/elf_scn.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libelf/elf_scn.c b/libelf/elf_scn.c
index b72fef66c46b..f702474f35b2 100644
--- a/libelf/elf_scn.c
+++ b/libelf/elf_scn.c
@@ -36,7 +36,7 @@
#include "_libelf.h"
-ELFTC_VCSID("$Id: elf_scn.c 3632 2018-10-10 21:12:43Z jkoshy $");
+ELFTC_VCSID("$Id: elf_scn.c 3712 2019-03-16 22:23:34Z jkoshy $");
/*
* Load an ELF section table and create a list of Elf_Scn structures.
@@ -58,10 +58,11 @@ _libelf_load_section_headers(Elf *e, void *ehdr)
assert((e->e_flags & LIBELF_F_SHDRS_LOADED) == 0);
#define CHECK_EHDR(E,EH) do { \
- if (shoff > e->e_rawsize || \
+ uintmax_t rawsize = (uintmax_t) e->e_rawsize; \
+ if (shoff > (uintmax_t) e->e_rawsize || \
fsz != (EH)->e_shentsize || \
shnum > SIZE_MAX / fsz || \
- fsz * shnum > e->e_rawsize - shoff) { \
+ fsz * shnum > rawsize - shoff) { \
LIBELF_SET_ERROR(HEADER, 0); \
return (0); \
} \