summaryrefslogtreecommitdiff
path: root/distrib/common/elfrd_size.c
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2017-12-03 19:32:20 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2017-12-03 19:32:20 +0000
commit83e5cb6e1ff93a4b130345b1a965e8126604fab8 (patch)
treeb2385b18f806499a01f36896f699dfc8bf68fee4 /distrib/common/elfrd_size.c
parent2286df923da16c107a4317f215cf3eb6fd0289ab (diff)
pledge(2) elfrdsetroot:
- pledge(2) "stdio" after managing arguments (opening files) - add $OpenBSD$ markers on elfrd_size.c and elfrdsetroot.h - add a check for NULL on malloc(3) call in elfrd_size.c from semarie, ok deraadt
Diffstat (limited to 'distrib/common/elfrd_size.c')
-rw-r--r--distrib/common/elfrd_size.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/distrib/common/elfrd_size.c b/distrib/common/elfrd_size.c
index 60bb1807585..d53442b69ff 100644
--- a/distrib/common/elfrd_size.c
+++ b/distrib/common/elfrd_size.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: elfrd_size.c,v 1.8 2017/12/03 19:32:19 tb Exp $ */
+
#include <sys/types.h>
#include <sys/file.h>
#include <sys/mman.h>
@@ -52,8 +54,10 @@ ELFNAME(locate_image)(int fd, struct elfhdr *ghead, char *file,
}
phsize = head.e_phnum * sizeof(Elf_Phdr);
- ph = malloc(phsize);
-
+ if ((ph = malloc(phsize)) == NULL) {
+ perror("malloc");
+ exit(1);
+ }
lseek(fd, head.e_phoff, SEEK_SET);