summaryrefslogtreecommitdiff
path: root/sys/compat/freebsd32/freebsd32_misc.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2018-04-19 16:00:34 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2018-04-19 16:00:34 +0000
commit73c8686e91350bb6a16ed918886fade28735a1ed (patch)
tree5f33436176d46381ab978c175471b6dc8ad70b35 /sys/compat/freebsd32/freebsd32_misc.c
parentb3e85e7a7993946dc9408e949911692f3d8a565f (diff)
downloadsrc-test2-73c8686e91350bb6a16ed918886fade28735a1ed.tar.gz
src-test2-73c8686e91350bb6a16ed918886fade28735a1ed.zip
Notes
Diffstat (limited to 'sys/compat/freebsd32/freebsd32_misc.c')
-rw-r--r--sys/compat/freebsd32/freebsd32_misc.c34
1 files changed, 11 insertions, 23 deletions
diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c
index 5cda21be68f8..35b5164d6be9 100644
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -3180,35 +3180,23 @@ freebsd32_copyout_strings(struct image_params *imgp)
destp -= ARG_MAX - imgp->args->stringspace;
destp = rounddown2(destp, sizeof(uint32_t));
- /*
- * If we have a valid auxargs ptr, prepare some room
- * on the stack.
- */
+ vectp = (uint32_t *)destp;
if (imgp->auxargs) {
/*
- * 'AT_COUNT*2' is size for the ELF Auxargs data. This is for
- * lower compatibility.
- */
- imgp->auxarg_size = (imgp->auxarg_size) ? imgp->auxarg_size
- : (AT_COUNT * 2);
- /*
- * The '+ 2' is for the null pointers at the end of each of
- * the arg and env vector sets,and imgp->auxarg_size is room
- * for argument of Runtime loader.
- */
- vectp = (u_int32_t *) (destp - (imgp->args->argc +
- imgp->args->envc + 2 + imgp->auxarg_size + execpath_len) *
- sizeof(u_int32_t));
- } else {
- /*
- * The '+ 2' is for the null pointers at the end of each of
- * the arg and env vector sets
+ * Allocate room on the stack for the ELF auxargs
+ * array. It has up to AT_COUNT entries.
*/
- vectp = (u_int32_t *)(destp - (imgp->args->argc +
- imgp->args->envc + 2) * sizeof(u_int32_t));
+ vectp -= howmany(AT_COUNT * sizeof(Elf32_Auxinfo),
+ sizeof(*vectp));
}
/*
+ * Allocate room for the argv[] and env vectors including the
+ * terminating NULL pointers.
+ */
+ vectp -= imgp->args->argc + 1 + imgp->args->envc + 1;
+
+ /*
* vectp also becomes our initial stack base
*/
stack_base = vectp;