summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2001-07-30 11:58:37 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2001-07-30 11:58:37 +0000
commit7e30b92f64324e3a7561a1bba30cf003e4037d76 (patch)
treeecc88716bd2bc466c6bfc34d82fb8cea3335ade9 /sys/kern
parentee84495193e2dd1b7afc925247e0e351281aa943 (diff)
Add a check for too big e_phnum that could cause us to malloc to
much and barf. This should have been merged into this file from exec_elf64.c a long time ago. Looking for volunteers to merge exec_elf.c and exec_elf64.c
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/exec_elf.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/sys/kern/exec_elf.c b/sys/kern/exec_elf.c
index 2eb09508aca..ed9c5d46536 100644
--- a/sys/kern/exec_elf.c
+++ b/sys/kern/exec_elf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec_elf.c,v 1.32 2001/06/22 14:14:07 deraadt Exp $ */
+/* $OpenBSD: exec_elf.c,v 1.33 2001/07/30 11:58:36 art Exp $ */
/*
* Copyright (c) 1996 Per Fogelstrom
@@ -189,6 +189,10 @@ elf_check_header(ehdr, type)
if (ehdr->e_type != type)
return (ENOEXEC);
+ /* Don't allow an insane amount of sections. */
+ if (ehdr->e_phnum > 128)
+ return (ENOEXEC);
+
return (0);
}
@@ -232,6 +236,10 @@ os_ok:
if (ehdr->e_type != type)
return (ENOEXEC);
+ /* Don't allow an insane amount of sections. */
+ if (ehdr->e_phnum > 128)
+ return (ENOEXEC);
+
*os = ehdr->e_ident[OI_OS];
return (0);
}