summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-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);
}