diff options
Diffstat (limited to 'lib/libelf/libelf_phdr.c')
-rw-r--r-- | lib/libelf/libelf_phdr.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/libelf/libelf_phdr.c b/lib/libelf/libelf_phdr.c index 8196ba426de..797a66977f0 100644 --- a/lib/libelf/libelf_phdr.c +++ b/lib/libelf/libelf_phdr.c @@ -31,7 +31,7 @@ #include "_libelf.h" -ELFTC_VCSID("$Id: libelf_phdr.c,v 1.1 2019/02/01 05:27:38 jsg Exp $"); +ELFTC_VCSID("$Id: libelf_phdr.c,v 1.2 2019/03/19 02:31:35 jsg Exp $"); void * _libelf_getphdr(Elf *e, int ec) @@ -77,6 +77,11 @@ _libelf_getphdr(Elf *e, int ec) assert(fsz > 0); + if (phoff + fsz < phoff) { /* Numeric overflow. */ + LIBELF_SET_ERROR(HEADER, 0); + return (NULL); + } + if ((uint64_t) e->e_rawsize < (phoff + fsz)) { LIBELF_SET_ERROR(HEADER, 0); return (NULL); |