From 4cab7525638d78c1a9008b39bfaa8e151aee6fba Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Mon, 10 Mar 2008 10:23:03 +0000 Subject: Merge db_input.c:1.39 from HEAD to RELENG_7: Reserve two bytes at the end of the DDB input line in db_readline() to hold the newline and nul terminator. Otherwise, there are cases where garbage may end up in the command history due to a lack of a nul terminator, or input may end up without room for a newline. PR: 119079 Submitted by: Michael Plass --- sys/ddb/db_input.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sys') diff --git a/sys/ddb/db_input.c b/sys/ddb/db_input.c index 4559122f7ef0..1d09307eadd0 100644 --- a/sys/ddb/db_input.c +++ b/sys/ddb/db_input.c @@ -302,6 +302,9 @@ db_readline(lstart, lsize) char * lstart; int lsize; { + + if (lsize < 2) + return (0); if (lsize != db_lhistlsize) { /* * (Re)initialize input line history. Throw away any @@ -316,7 +319,7 @@ db_readline(lstart, lsize) db_force_whitespace(); /* synch output position */ db_lbuf_start = lstart; - db_lbuf_end = lstart + lsize; + db_lbuf_end = lstart + lsize - 2; /* Will append NL and NUL. */ db_lc = lstart; db_le = lstart; -- cgit v1.3