summaryrefslogtreecommitdiffstats
path: root/sys/compat
diff options
context:
space:
mode:
authorups <ups@FreeBSD.org>2006-03-08 20:21:54 +0000
committerups <ups@FreeBSD.org>2006-03-08 20:21:54 +0000
commit5ad34fd1d66bc05d173c6cb735719eb37f569e12 (patch)
tree39948a2c849c6cb6cd1653c28bec99e658acf320 /sys/compat
parentedc000b320776d276fa4e27697ec56b442e934a5 (diff)
downloadFreeBSD-src-5ad34fd1d66bc05d173c6cb735719eb37f569e12.zip
FreeBSD-src-5ad34fd1d66bc05d173c6cb735719eb37f569e12.tar.gz
Fix exec_map resource leaks.
Tested by: kris@
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/freebsd32/freebsd32_misc.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c
index 1045d12..472ef24 100644
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -260,7 +260,7 @@ freebsd32_exec_copyin_args(struct image_args *args, char *fname,
copystr(fname, args->fname, PATH_MAX, &length) :
copyinstr(fname, args->fname, PATH_MAX, &length);
if (error != 0)
- return (error);
+ goto err_exit;
/*
* extract arguments first
@@ -269,16 +269,15 @@ freebsd32_exec_copyin_args(struct image_args *args, char *fname,
for (;;) {
error = copyin(p32++, &arg, sizeof(arg));
if (error)
- return (error);
+ goto err_exit;
if (arg == 0)
break;
argp = PTRIN(arg);
error = copyinstr(argp, args->endp, args->stringspace, &length);
if (error) {
if (error == ENAMETOOLONG)
- return (E2BIG);
- else
- return (error);
+ error = E2BIG;
+ goto err_exit;
}
args->stringspace -= length;
args->endp += length;
@@ -295,7 +294,7 @@ freebsd32_exec_copyin_args(struct image_args *args, char *fname,
for (;;) {
error = copyin(p32++, &arg, sizeof(arg));
if (error)
- return (error);
+ goto err_exit;
if (arg == 0)
break;
envp = PTRIN(arg);
@@ -303,9 +302,8 @@ freebsd32_exec_copyin_args(struct image_args *args, char *fname,
&length);
if (error) {
if (error == ENAMETOOLONG)
- return (E2BIG);
- else
- return (error);
+ error = E2BIG;
+ goto err_exit;
}
args->stringspace -= length;
args->endp += length;
@@ -314,6 +312,12 @@ freebsd32_exec_copyin_args(struct image_args *args, char *fname,
}
return (0);
+
+err_exit:
+ kmem_free_wakeup(exec_map, (vm_offset_t)args->buf,
+ PATH_MAX + ARG_MAX + MAXSHELLCMDLEN);
+ args->buf = NULL;
+ return (error);
}
int
OpenPOWER on IntegriCloud