- 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
+/* $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>
}
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);
-/* $OpenBSD: elfrdsetroot.c,v 1.24 2017/10/29 08:45:53 mpi Exp $ */
+/* $OpenBSD: elfrdsetroot.c,v 1.25 2017/12/03 19:32:19 tb Exp $ */
/* $NetBSD: rdsetroot.c,v 1.2 1995/10/13 16:38:39 gwr Exp $ */
/*
exit(1);
}
+ if (pledge("stdio", NULL) == -1) {
+ perror("pledge");
+ exit(1);
+ }
+
n = read(fd, &head, sizeof(head));
if (n < sizeof(head)) {
fprintf(stderr, "%s: reading header\n", file);
+/* $OpenBSD: elfrdsetroot.h,v 1.3 2017/12/03 19:32:19 tb Exp $ */
+
struct elf_fn {
void (*locate_image)(int, struct elfhdr *, char *, long *, long *,
off_t *, size_t *);