summaryrefslogtreecommitdiff
path: root/lib/libelf/libelf_phdr.c
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2019-03-19 02:31:36 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2019-03-19 02:31:36 +0000
commitcf0274fe9f59233533a1cc96887748298971c367 (patch)
treeb9c80402e35d2d4f5ff38a750476ab4c3dd26915 /lib/libelf/libelf_phdr.c
parente69491f952dc7794ee3a52e768fa6028c5be8e0b (diff)
update libelf from elftoolchain r3669 to r3714
includes changes to address problems sunil@ found with fuzzing original diff from and ok sunil@
Diffstat (limited to 'lib/libelf/libelf_phdr.c')
-rw-r--r--lib/libelf/libelf_phdr.c7
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);