summaryrefslogtreecommitdiff
path: root/sys/compat/linux/common/linux_break.c
diff options
context:
space:
mode:
authorfvdl <fvdl@NetBSD.org>1995-08-21 23:15:51 +0000
committerfvdl <fvdl@NetBSD.org>1995-08-21 23:15:51 +0000
commit7cd62a508cbead46f0d2d133d0efdbee309b2990 (patch)
treec78419ab26b526816d0a065671c5e423f17bac5b /sys/compat/linux/common/linux_break.c
parent7560ab9b686d27c8a685e2c76cfd4f1b67ca379c (diff)
Check for status NULL argument in wait4 and waitpid. From PR #1392
by Thomas EberHardt.
Diffstat (limited to 'sys/compat/linux/common/linux_break.c')
-rw-r--r--sys/compat/linux/common/linux_break.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/sys/compat/linux/common/linux_break.c b/sys/compat/linux/common/linux_break.c
index c4ace7b7676..7d9bf38c21b 100644
--- a/sys/compat/linux/common/linux_break.c
+++ b/sys/compat/linux/common/linux_break.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_break.c,v 1.15 1995/08/21 03:42:09 mycroft Exp $ */
+/* $NetBSD: linux_break.c,v 1.16 1995/08/21 23:15:51 fvdl Exp $ */
/*
* Copyright (c) 1995 Frank van der Linden
@@ -112,8 +112,11 @@ linux_waitpid(p, uap, retval)
int error, *status, tstat;
caddr_t sg;
- sg = stackgap_init(p->p_emul);
- status = (int *) stackgap_alloc(&sg, sizeof status);
+ if (SCARG(uap, status) != NULL) {
+ sg = stackgap_init(p->p_emul);
+ status = (int *) stackgap_alloc(&sg, sizeof status);
+ } else
+ status = NULL;
SCARG(&w4a, pid) = SCARG(uap, pid);
SCARG(&w4a, status) = status;
@@ -123,12 +126,16 @@ linux_waitpid(p, uap, retval)
if ((error = wait4(p, &w4a, retval)))
return error;
- if ((error = copyin(status, &tstat, sizeof tstat)))
- return error;
+ if (status != NULL) {
+ if ((error = copyin(status, &tstat, sizeof tstat)))
+ return error;
- bsd_to_linux_wstat(&tstat);
+ bsd_to_linux_wstat(&tstat);
- return copyout(&tstat, SCARG(uap, status), sizeof tstat);
+ return copyout(&tstat, SCARG(uap, status), sizeof tstat);
+ }
+
+ return 0;
}
/*
@@ -149,8 +156,11 @@ linux_wait4(p, uap, retval)
int error, *status, tstat;
caddr_t sg;
- sg = stackgap_init(p->p_emul);
- status = (int *) stackgap_alloc(&sg, sizeof status);
+ if (SCARG(uap, status) != NULL) {
+ sg = stackgap_init(p->p_emul);
+ status = (int *) stackgap_alloc(&sg, sizeof status);
+ } else
+ status = NULL;
SCARG(&w4a, pid) = SCARG(uap, pid);
SCARG(&w4a, status) = status;
@@ -160,12 +170,16 @@ linux_wait4(p, uap, retval)
if ((error = wait4(p, &w4a, retval)))
return error;
- if ((error = copyin(status, &tstat, sizeof tstat)))
- return error;
+ if (status != NULL) {
+ if ((error = copyin(status, &tstat, sizeof tstat)))
+ return error;
- bsd_to_linux_wstat(&tstat);
+ bsd_to_linux_wstat(&tstat);
- return copyout(&tstat, SCARG(uap, status), sizeof tstat);
+ return copyout(&tstat, SCARG(uap, status), sizeof tstat);
+ }
+
+ return 0;
}
/*