Fix an off-by-one buffer overflow in ngets().

Submitted by:	Bruce Can
MFC after:	1 month
This commit is contained in:
John Baldwin 2009-03-31 14:30:46 +00:00
parent fa01cfefc2
commit b0d8ed7ad3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=190593

View File

@ -74,7 +74,7 @@ ngets(char *buf, int n)
putchar('\n');
break;
default:
if ((n < 1) || ((lp - buf) < n)) {
if ((n < 1) || ((lp - buf) < n - 1)) {
*lp++ = c;
putchar(c);
}