summaryrefslogtreecommitdiff
path: root/lib/libelf
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2015-01-23 04:07:07 +0000
committerEd Maste <emaste@FreeBSD.org>2015-01-23 04:07:07 +0000
commit46644e84ad0ad2f5add18f5cc79bfb3d093e6c65 (patch)
tree2daa2fb7a8a7a2ccc8ff65592528be559bf43e38 /lib/libelf
parentad829d625ccd30e91a575c52e88c047c60f53a00 (diff)
Notes
Diffstat (limited to 'lib/libelf')
-rw-r--r--lib/libelf/elf_scn.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/libelf/elf_scn.c b/lib/libelf/elf_scn.c
index 2eefca1512e3..5b2b3c7765c2 100644
--- a/lib/libelf/elf_scn.c
+++ b/lib/libelf/elf_scn.c
@@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$");
#include <errno.h>
#include <gelf.h>
#include <libelf.h>
+#include <stdint.h>
#include <stdlib.h>
#include "_libelf.h"
@@ -55,8 +56,10 @@ _libelf_load_scn(Elf *e, void *ehdr)
assert((e->e_flags & LIBELF_F_SHDRS_LOADED) == 0);
#define CHECK_EHDR(E,EH) do { \
- if (fsz != (EH)->e_shentsize || \
- shoff + fsz * shnum > e->e_rawsize) { \
+ if (shoff > e->e_rawsize || \
+ fsz != (EH)->e_shentsize || \
+ shnum > SIZE_MAX / fsz || \
+ fsz * shnum > e->e_rawsize - shoff) { \
LIBELF_SET_ERROR(HEADER, 0); \
return (0); \
} \