return ERANGE if the buffer is too small to contain the login as documented in

the manpage

Reviewed by:	cognet, kib
MFC after:	1 month
This commit is contained in:
Baptiste Daroussin 2012-11-14 10:32:12 +00:00
parent 23454ad0e2
commit 6f68699fbd

View File

@ -2084,6 +2084,8 @@ sys_getlogin(struct thread *td, struct getlogin_args *uap)
bcopy(p->p_session->s_login, login, uap->namelen);
SESS_UNLOCK(p->p_session);
PROC_UNLOCK(p);
if (strlen(login) + 1 > uap->namelen)
return (ERANGE);
error = copyout(login, uap->namebuf, uap->namelen);
return(error);
}