summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorart <art@openbsd.org>2001-03-29 13:25:34 +0000
committerart <art@openbsd.org>2001-03-29 13:25:34 +0000
commit9f186dc3e13ed0b330be51a2ad90b9200a6109e3 (patch)
tree0243130b118f119b4328f3f474132e2b7b908bfb /sys
parentApache 1.3.19+mod_ssl 2.8.1 merge - also adds shared build of mod_headers (diff)
downloadwireguard-openbsd-9f186dc3e13ed0b330be51a2ad90b9200a6109e3.tar.xz
wireguard-openbsd-9f186dc3e13ed0b330be51a2ad90b9200a6109e3.zip
Kludge around a problem where incorrect elf headers can cause
us to allocate too much memory in kmem_map and barf. This solution is completly bogus but it is the best I can do right now.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/exec_elf64.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/sys/kern/exec_elf64.c b/sys/kern/exec_elf64.c
index e0cc9e602f3..39cc5ec1180 100644
--- a/sys/kern/exec_elf64.c
+++ b/sys/kern/exec_elf64.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec_elf64.c,v 1.13 2001/03/07 00:56:30 niklas Exp $ */
+/* $OpenBSD: exec_elf64.c,v 1.14 2001/03/29 13:25:34 art Exp $ */
/*
* Copyright (c) 1996 Per Fogelstrom
@@ -400,6 +400,11 @@ elf64_load_file(p, path, epp, ap, last)
}
phsize = eh.e_phnum * sizeof(Elf64_Phdr);
+ if (phsize > 8192) {
+ /* XXX - this is not the way we want to fix this, but ... */
+ error = EINVAL;
+ goto bad1;
+ }
ph = (Elf64_Phdr *)malloc(phsize, M_TEMP, M_WAITOK);
if ((error = elf64_read_from(p, nd.ni_vp, eh.e_phoff, (caddr_t)ph,
@@ -789,6 +794,10 @@ elf64_os_pt_note(p, epp, eh, os_name, name_size, desc_size)
int error;
phsize = eh->e_phnum * sizeof(Elf64_Phdr);
+ if (phsize > 8192) {
+ /* XXX - this is not the way we want to fix this, but ... */
+ return EINVAL;
+ }
hph = (Elf64_Phdr *)malloc(phsize, M_TEMP, M_WAITOK);
if ((error = elf64_read_from(p, epp->ep_vp, eh->e_phoff,
(caddr_t)hph, phsize)) != 0)