summaryrefslogtreecommitdiffstats
path: root/sys/kern/imgact_elf.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2009-10-10 15:28:52 +0000
committerkib <kib@FreeBSD.org>2009-10-10 15:28:52 +0000
commit16ff64e8c6636314a9d07e743e481c2d58bcb7a4 (patch)
tree0ce49a1acb0e5e500f86d387de1312036ae440ec /sys/kern/imgact_elf.c
parent69e50b966ca53e391bd55d3f7a8889a4f52e0df6 (diff)
downloadFreeBSD-src-16ff64e8c6636314a9d07e743e481c2d58bcb7a4.zip
FreeBSD-src-16ff64e8c6636314a9d07e743e481c2d58bcb7a4.tar.gz
Do not map segments of zero length.
Discussed with: bz Reviewed by: kan Tested by: bz (i386, amd64), bsam (linux) MFC after: some time
Diffstat (limited to 'sys/kern/imgact_elf.c')
-rw-r--r--sys/kern/imgact_elf.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
index 4ed7382..3841d1f 100644
--- a/sys/kern/imgact_elf.c
+++ b/sys/kern/imgact_elf.c
@@ -635,7 +635,8 @@ __elfN(load_file)(struct proc *p, const char *file, u_long *addr,
}
for (i = 0, numsegs = 0; i < hdr->e_phnum; i++) {
- if (phdr[i].p_type == PT_LOAD) { /* Loadable segment */
+ if (phdr[i].p_type == PT_LOAD && phdr[i].p_memsz != 0) {
+ /* Loadable segment */
prot = 0;
if (phdr[i].p_flags & PF_X)
prot |= VM_PROT_EXECUTE;
@@ -764,6 +765,8 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp)
for (i = 0; i < hdr->e_phnum; i++) {
switch (phdr[i].p_type) {
case PT_LOAD: /* Loadable segment */
+ if (phdr[i].p_memsz == 0)
+ break;
prot = 0;
if (phdr[i].p_flags & PF_X)
prot |= VM_PROT_EXECUTE;
OpenPOWER on IntegriCloud