getpgid() and getsid() were doing a comparision rather than an assignment,

which is fortunate, because otherwise another bug would allow them to be
used to stomp on the syscall return value of another process.
This commit is contained in:
Don Lewis 1998-12-13 07:07:51 +00:00
parent d6a2c91a12
commit 65de0c7a93

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* @(#)kern_prot.c 8.6 (Berkeley) 1/21/94 * @(#)kern_prot.c 8.6 (Berkeley) 1/21/94
* $Id: kern_prot.c,v 1.41 1998/11/09 15:07:42 truckman Exp $ * $Id: kern_prot.c,v 1.42 1998/11/10 09:16:29 peter Exp $
*/ */
/* /*
@ -122,13 +122,16 @@ getpgid(p, uap)
struct proc *p; struct proc *p;
struct getpgid_args *uap; struct getpgid_args *uap;
{ {
struct proc *pt;
pt = p;
if (uap->pid == 0) if (uap->pid == 0)
goto found; goto found;
if ((p == pfind(uap->pid)) == 0) if ((pt = pfind(uap->pid)) == 0)
return ESRCH; return ESRCH;
found: found:
p->p_retval[0] = p->p_pgrp->pg_id; p->p_retval[0] = pt->p_pgrp->pg_id;
return 0; return 0;
} }
@ -146,13 +149,16 @@ getsid(p, uap)
struct proc *p; struct proc *p;
struct getsid_args *uap; struct getsid_args *uap;
{ {
struct proc *pt;
pt = p;
if (uap->pid == 0) if (uap->pid == 0)
goto found; goto found;
if ((p == pfind(uap->pid)) == 0) if ((pt == pfind(uap->pid)) == 0)
return ESRCH; return ESRCH;
found: found:
p->p_retval[0] = p->p_session->s_sid; p->p_retval[0] = pt->p_session->s_sid;
return 0; return 0;
} }