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

Submitted by:	Bruce Can
MFC after:	1 month
This commit is contained in:
jhb 2009-03-31 14:30:46 +00:00
parent 4e28805a1b
commit 6368eeb9b5

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);
}