diff options
| author | fvdl <fvdl@NetBSD.org> | 1995-08-21 23:15:51 +0000 |
|---|---|---|
| committer | fvdl <fvdl@NetBSD.org> | 1995-08-21 23:15:51 +0000 |
| commit | 7cd62a508cbead46f0d2d133d0efdbee309b2990 (patch) | |
| tree | c78419ab26b526816d0a065671c5e423f17bac5b /sys/compat/linux/common | |
| parent | 7560ab9b686d27c8a685e2c76cfd4f1b67ca379c (diff) | |
Check for status NULL argument in wait4 and waitpid. From PR #1392
by Thomas EberHardt.
Diffstat (limited to 'sys/compat/linux/common')
| -rw-r--r-- | sys/compat/linux/common/linux_break.c | 40 | ||||
| -rw-r--r-- | sys/compat/linux/common/linux_misc.c | 40 | ||||
| -rw-r--r-- | sys/compat/linux/common/linux_misc_notalpha.c | 40 | ||||
| -rw-r--r-- | sys/compat/linux/common/linux_oldmmap.c | 40 | ||||
| -rw-r--r-- | sys/compat/linux/common/linux_oldolduname.c | 40 | ||||
| -rw-r--r-- | sys/compat/linux/common/linux_oldselect.c | 40 | ||||
| -rw-r--r-- | sys/compat/linux/common/linux_olduname.c | 40 | ||||
| -rw-r--r-- | sys/compat/linux/common/linux_pipe.c | 40 |
8 files changed, 216 insertions, 104 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; } /* diff --git a/sys/compat/linux/common/linux_misc.c b/sys/compat/linux/common/linux_misc.c index 377cb4abd8c..811011aff64 100644 --- a/sys/compat/linux/common/linux_misc.c +++ b/sys/compat/linux/common/linux_misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_misc.c,v 1.15 1995/08/21 03:42:09 mycroft Exp $ */ +/* $NetBSD: linux_misc.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; } /* diff --git a/sys/compat/linux/common/linux_misc_notalpha.c b/sys/compat/linux/common/linux_misc_notalpha.c index a04e0ebf16b..6c42b4275a7 100644 --- a/sys/compat/linux/common/linux_misc_notalpha.c +++ b/sys/compat/linux/common/linux_misc_notalpha.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_misc_notalpha.c,v 1.15 1995/08/21 03:42:09 mycroft Exp $ */ +/* $NetBSD: linux_misc_notalpha.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; } /* diff --git a/sys/compat/linux/common/linux_oldmmap.c b/sys/compat/linux/common/linux_oldmmap.c index 44bf4457a5f..9c60edce64e 100644 --- a/sys/compat/linux/common/linux_oldmmap.c +++ b/sys/compat/linux/common/linux_oldmmap.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_oldmmap.c,v 1.15 1995/08/21 03:42:09 mycroft Exp $ */ +/* $NetBSD: linux_oldmmap.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; } /* diff --git a/sys/compat/linux/common/linux_oldolduname.c b/sys/compat/linux/common/linux_oldolduname.c index e524249850d..4c418b84c3e 100644 --- a/sys/compat/linux/common/linux_oldolduname.c +++ b/sys/compat/linux/common/linux_oldolduname.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_oldolduname.c,v 1.15 1995/08/21 03:42:09 mycroft Exp $ */ +/* $NetBSD: linux_oldolduname.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; } /* diff --git a/sys/compat/linux/common/linux_oldselect.c b/sys/compat/linux/common/linux_oldselect.c index 4baf6ef8070..2023c5752b2 100644 --- a/sys/compat/linux/common/linux_oldselect.c +++ b/sys/compat/linux/common/linux_oldselect.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_oldselect.c,v 1.15 1995/08/21 03:42:09 mycroft Exp $ */ +/* $NetBSD: linux_oldselect.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; } /* diff --git a/sys/compat/linux/common/linux_olduname.c b/sys/compat/linux/common/linux_olduname.c index e445e39f1e8..2ae8bb08fc0 100644 --- a/sys/compat/linux/common/linux_olduname.c +++ b/sys/compat/linux/common/linux_olduname.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_olduname.c,v 1.15 1995/08/21 03:42:09 mycroft Exp $ */ +/* $NetBSD: linux_olduname.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; } /* diff --git a/sys/compat/linux/common/linux_pipe.c b/sys/compat/linux/common/linux_pipe.c index 46d923190fe..73686f00945 100644 --- a/sys/compat/linux/common/linux_pipe.c +++ b/sys/compat/linux/common/linux_pipe.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_pipe.c,v 1.15 1995/08/21 03:42:09 mycroft Exp $ */ +/* $NetBSD: linux_pipe.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; } /* |
