aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/cloudabi64
diff options
context:
space:
mode:
authorBrooks Davis <brooks@FreeBSD.org>2018-11-29 21:00:56 +0000
committerBrooks Davis <brooks@FreeBSD.org>2018-11-29 21:00:56 +0000
commitf373437a01a361a76e3ba53e057d025e6536d0fd (patch)
tree48d4d749d3e70f2736330d671e4b721ff5c3debd /sys/compat/cloudabi64
parentdead7b5e47d14f6560c5be40e673664ba20c670f (diff)
downloadsrc-f373437a01a361a76e3ba53e057d025e6536d0fd.tar.gz
src-f373437a01a361a76e3ba53e057d025e6536d0fd.zip
Add helper functions to copy strings into struct image_args.
Given a zeroed struct image_args with an allocated buf member, exec_args_add_fname() must be called to install a file name (or NULL). Then zero or more calls to exec_args_add_env() followed by zero or more calls to exec_args_add_env(). exec_args_adjust_args() may be called after args and/or env to allow an interpreter to be prepended to the argument list. To allow code reuse when adding arg and env variables, begin_envv should be accessed with the accessor exec_args_get_begin_envv() which handles the case when no environment entries have been added. Use these functions to simplify exec_copyin_args() and freebsd32_exec_copyin_args(). Reviewed by: kib Obtained from: CheriBSD Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D15468
Notes
Notes: svn path=/head/; revision=341263
Diffstat (limited to 'sys/compat/cloudabi64')
-rw-r--r--sys/compat/cloudabi64/cloudabi64_module.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/compat/cloudabi64/cloudabi64_module.c b/sys/compat/cloudabi64/cloudabi64_module.c
index 9c71b87b08f4..fd0be086aac3 100644
--- a/sys/compat/cloudabi64/cloudabi64_module.c
+++ b/sys/compat/cloudabi64/cloudabi64_module.c
@@ -54,7 +54,7 @@ cloudabi64_copyout_strings(struct image_params *imgp)
/* Copy out program arguments. */
args = imgp->args;
- len = args->begin_envv - args->begin_argv;
+ len = exec_args_get_begin_envv(args) - args->begin_argv;
begin = rounddown2(imgp->sysent->sv_usrstack - len, sizeof(register_t));
copyout(args->begin_argv, (void *)begin, len);
return ((register_t *)begin);
@@ -109,7 +109,8 @@ cloudabi64_fixup(register_t **stack_base, struct image_params *imgp)
* exec_copyin_data_fds(). Undo this by reducing the length.
*/
args = (Elf64_Auxargs *)imgp->auxargs;
- argdatalen = imgp->args->begin_envv - imgp->args->begin_argv;
+ argdatalen = exec_args_get_begin_envv(imgp->args) -
+ imgp->args->begin_argv;
if (argdatalen > 0)
--argdatalen;