Fix off by one error in setlogin() syscall.
Don't overwrite session login unless the call is going to succeed.
This commit is contained in:
parent
996c772f58
commit
184989c210
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=22522
@ -683,13 +683,16 @@ setlogin(p, uap, retval)
|
||||
int *retval;
|
||||
{
|
||||
int error;
|
||||
char logintmp[sizeof(p->p_pgrp->pg_session->s_login)];
|
||||
|
||||
if ((error = suser(p->p_ucred, &p->p_acflag)))
|
||||
return (error);
|
||||
error = copyinstr((caddr_t) uap->namebuf,
|
||||
(caddr_t) p->p_pgrp->pg_session->s_login,
|
||||
sizeof (p->p_pgrp->pg_session->s_login) - 1, (u_int *)0);
|
||||
error = copyinstr((caddr_t) uap->namebuf, (caddr_t) logintmp,
|
||||
sizeof(logintmp), (u_int *)0);
|
||||
if (error == ENAMETOOLONG)
|
||||
error = EINVAL;
|
||||
else if (!error)
|
||||
(void) memcpy(p->p_pgrp->pg_session->s_login, logintmp,
|
||||
sizeof(p->p_pgrp->pg_session->s_login));
|
||||
return (error);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user