diff options
author | jilles <jilles@FreeBSD.org> | 2016-10-11 18:51:03 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2016-10-11 18:51:03 +0000 |
commit | 869c696c42a93d91f91468cb3e5eb89d51d024b8 (patch) | |
tree | 94481d3ae1b8715eae8a325b99a2380fbf25aaae /sys/kern/kern_exit.c | |
parent | 34a2159fba1475d12ce7171ff4e0f4ace8822623 (diff) | |
download | FreeBSD-src-869c696c42a93d91f91468cb3e5eb89d51d024b8.zip FreeBSD-src-869c696c42a93d91f91468cb3e5eb89d51d024b8.tar.gz |
wait: Do not copyout uninitialized status/rusage/wrusage.
If wait4() or wait6() return 0 because of WNOHANG, the status, rusage and
wrusage information should not be returned.
PR: 212048
Reported by: Casey Lucas
Diffstat (limited to 'sys/kern/kern_exit.c')
-rw-r--r-- | sys/kern/kern_exit.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index c362530..3602cbb 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -785,9 +785,9 @@ sys_wait4(struct thread *td, struct wait4_args *uap) else rup = NULL; error = kern_wait(td, uap->pid, &status, uap->options, rup); - if (uap->status != NULL && error == 0) + if (uap->status != NULL && error == 0 && td->td_retval[0] != 0) error = copyout(&status, uap->status, sizeof(status)); - if (uap->rusage != NULL && error == 0) + if (uap->rusage != NULL && error == 0 && td->td_retval[0] != 0) error = copyout(&ru, uap->rusage, sizeof(struct rusage)); return (error); } @@ -821,9 +821,9 @@ sys_wait6(struct thread *td, struct wait6_args *uap) */ error = kern_wait6(td, idtype, id, &status, uap->options, wrup, sip); - if (uap->status != NULL && error == 0) + if (uap->status != NULL && error == 0 && td->td_retval[0] != 0) error = copyout(&status, uap->status, sizeof(status)); - if (uap->wrusage != NULL && error == 0) + if (uap->wrusage != NULL && error == 0 && td->td_retval[0] != 0) error = copyout(&wru, uap->wrusage, sizeof(wru)); if (uap->info != NULL && error == 0) error = copyout(&si, uap->info, sizeof(si)); |