summaryrefslogtreecommitdiff
path: root/sys/lib/libsa
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2009-11-30 05:18:09 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2009-11-30 05:18:09 +0000
commitad09fdc7ec83e11cbd34700b0c24c204bbc05cdb (patch)
tree926249d1c33d2fd53d05790d98f6d8d022737ee3 /sys/lib/libsa
parente54f442105ee2dd1c3bd2b954328a6e8969922dd (diff)
Allow the bootblocks to provide an optional Elfxx_Phdr check, and abort the
file load if necessary. Will be used very shortly.
Diffstat (limited to 'sys/lib/libsa')
-rw-r--r--sys/lib/libsa/loadfile_elf.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sys/lib/libsa/loadfile_elf.c b/sys/lib/libsa/loadfile_elf.c
index ca7d449e7d5..834a295ca10 100644
--- a/sys/lib/libsa/loadfile_elf.c
+++ b/sys/lib/libsa/loadfile_elf.c
@@ -1,5 +1,5 @@
/* $NetBSD: loadfile.c,v 1.10 2000/12/03 02:53:04 tsutsui Exp $ */
-/* $OpenBSD: loadfile_elf.c,v 1.5 2008/06/26 05:42:20 ray Exp $ */
+/* $OpenBSD: loadfile_elf.c,v 1.6 2009/11/30 05:18:08 miod Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -95,11 +95,17 @@ ELFNAME(exec)(int fd, Elf_Ehdr *elf, u_long *marks, int flags)
}
for (first = 1, i = 0; i < elf->e_phnum; i++) {
-
if (phdr[i].p_type != PT_LOAD ||
(phdr[i].p_flags & (PF_W|PF_R|PF_X)) == 0)
continue;
+#ifdef CHECK_PHDR
+ if (CHECK_PHDR(ELFSIZE, &phdr[i])) {
+ FREE(phdr, sz);
+ return 1;
+ }
+#endif
+
#define IS_TEXT(p) (p.p_flags & PF_X)
#define IS_DATA(p) ((p.p_flags & PF_X) == 0)
#define IS_BSS(p) (p.p_filesz < p.p_memsz)