1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-20 02:38:43 +00:00

Fix an out-of-bounds write when a zero-length buffer is passed.

Found with ttyname_test and CHERI bounds checking.

Reviewed by:	emaste
Obtained from:	CheriBSD
MFC after:	1 week
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D10377
This commit is contained in:
Brooks Davis 2017-04-13 15:52:45 +00:00
parent 33c72b24de
commit 8439a7220d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=316768

View File

@ -61,6 +61,10 @@ ttyname_r(int fd, char *buf, size_t len)
{
size_t used;
/* Don't write off the end of a zero-length buffer. */
if (len < 1)
return (ERANGE);
*buf = '\0';
/* Must be a terminal. */