summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/compat/freebsd32/freebsd32_misc.c11
-rw-r--r--sys/kern/imgact_shell.c14
-rw-r--r--sys/kern/kern_exec.c14
-rw-r--r--sys/vm/vm_init.c4
4 files changed, 24 insertions, 19 deletions
diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c
index 2d5c76d..1144f80 100644
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -286,22 +286,23 @@ freebsd32_exec_copyin_args(struct image_args *args, char *fname,
PATH_MAX + ARG_MAX + MAXSHELLCMDLEN);
if (args->buf == NULL)
return (ENOMEM);
- args->begin_argv = args->buf;
- args->endp = args->begin_argv;
- args->stringspace = ARG_MAX;
/*
* Copy the file name.
*/
if (fname != NULL) {
- args->fname = args->buf + ARG_MAX;
+ args->fname = args->buf + MAXSHELLCMDLEN;
error = (segflg == UIO_SYSSPACE) ?
copystr(fname, args->fname, PATH_MAX, &length) :
copyinstr(fname, args->fname, PATH_MAX, &length);
if (error != 0)
goto err_exit;
} else
- args->fname = NULL;
+ length = 0;
+
+ args->begin_argv = args->buf + MAXSHELLCMDLEN + length;
+ args->endp = args->begin_argv;
+ args->stringspace = ARG_MAX;
/*
* extract arguments first
diff --git a/sys/kern/imgact_shell.c b/sys/kern/imgact_shell.c
index e0248a7..5eb3065 100644
--- a/sys/kern/imgact_shell.c
+++ b/sys/kern/imgact_shell.c
@@ -220,13 +220,13 @@ exec_shell_imgact(imgp)
* the interpreter name and options-string.
*/
length = interpe - interpb;
- bcopy(interpb, imgp->args->buf, length);
- *(imgp->args->buf + length) = '\0';
+ bcopy(interpb, imgp->args->begin_argv, length);
+ *(imgp->args->begin_argv + length) = '\0';
offset = length + 1;
if (opte > optb) {
length = opte - optb;
- bcopy(optb, imgp->args->buf + offset, length);
- *(imgp->args->buf + offset + length) = '\0';
+ bcopy(optb, imgp->args->begin_argv + offset, length);
+ *(imgp->args->begin_argv + offset + length) = '\0';
offset += length + 1;
imgp->args->argc++;
}
@@ -236,12 +236,12 @@ exec_shell_imgact(imgp)
* use and copy the interpreter's name to imgp->interpreter_name
* for exec to use.
*/
- error = copystr(fname, imgp->args->buf + offset, imgp->args->stringspace,
- &length);
+ error = copystr(fname, imgp->args->begin_argv + offset,
+ imgp->args->stringspace, NULL);
if (error == 0)
error = copystr(imgp->args->begin_argv, imgp->interpreter_name,
- MAXSHELLCMDLEN, &length);
+ MAXSHELLCMDLEN, NULL);
if (sname != NULL)
sbuf_delete(sname);
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 1fa7444..1f0944c 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -375,7 +375,7 @@ do_execve(td, args, mac_p)
imgp->vmspace_destroyed = 0;
imgp->interpreted = 0;
imgp->opened = 0;
- imgp->interpreter_name = args->buf + PATH_MAX + ARG_MAX;
+ imgp->interpreter_name = args->buf;
imgp->auxargs = NULL;
imgp->vp = NULL;
imgp->object = NULL;
@@ -1089,21 +1089,23 @@ exec_copyin_args(struct image_args *args, char *fname,
PATH_MAX + ARG_MAX + MAXSHELLCMDLEN);
if (args->buf == NULL)
return (ENOMEM);
- args->begin_argv = args->buf;
- args->endp = args->begin_argv;
- args->stringspace = ARG_MAX;
+
/*
* Copy the file name.
*/
if (fname != NULL) {
- args->fname = args->buf + ARG_MAX;
+ args->fname = args->buf + MAXSHELLCMDLEN;
error = (segflg == UIO_SYSSPACE) ?
copystr(fname, args->fname, PATH_MAX, &length) :
copyinstr(fname, args->fname, PATH_MAX, &length);
if (error != 0)
goto err_exit;
} else
- args->fname = NULL;
+ length = 0;
+
+ args->begin_argv = args->buf + MAXSHELLCMDLEN + length;
+ args->endp = args->begin_argv;
+ args->stringspace = ARG_MAX;
/*
* extract arguments first
diff --git a/sys/vm/vm_init.c b/sys/vm/vm_init.c
index fdffb46..8775937 100644
--- a/sys/vm/vm_init.c
+++ b/sys/vm/vm_init.c
@@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <sys/selinfo.h>
+#include <sys/imgact.h>
#include <sys/pipe.h>
#include <sys/bio.h>
#include <sys/buf.h>
@@ -194,7 +195,8 @@ again:
(long)nswbuf * MAXPHYS, FALSE);
pager_map->system_map = 1;
exec_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr,
- exec_map_entries * (ARG_MAX + (PAGE_SIZE * 3)), FALSE);
+ exec_map_entries * round_page(PATH_MAX + ARG_MAX + MAXSHELLCMDLEN),
+ FALSE);
pipe_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr, maxpipekva,
FALSE);
OpenPOWER on IntegriCloud