Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Nov 2012 10:32:12 +0000 (UTC)
From:      Baptiste Daroussin <bapt@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r243021 - head/sys/kern
Message-ID:  <201211141032.qAEAWCk7052981@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bapt
Date: Wed Nov 14 10:32:12 2012
New Revision: 243021
URL: http://svnweb.freebsd.org/changeset/base/243021

Log:
  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

Modified:
  head/sys/kern/kern_prot.c

Modified: head/sys/kern/kern_prot.c
==============================================================================
--- head/sys/kern/kern_prot.c	Wed Nov 14 10:06:50 2012	(r243020)
+++ head/sys/kern/kern_prot.c	Wed Nov 14 10:32:12 2012	(r243021)
@@ -2084,6 +2084,8 @@ sys_getlogin(struct thread *td, struct g
 	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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201211141032.qAEAWCk7052981>