diff options
author | Robert Watson <rwatson@FreeBSD.org> | 2008-03-07 13:13:17 +0000 |
---|---|---|
committer | Robert Watson <rwatson@FreeBSD.org> | 2008-03-07 13:13:17 +0000 |
commit | 233f8184ecfa5df4a666a64792a97db0ecdc9d66 (patch) | |
tree | c930445d919e3cc3dee3f930cbdd31bb97dfc71d /sys/ddb/db_input.c | |
parent | 02f27f1cfa619cdf9509c65366f55f7c8803de5c (diff) | |
download | src-233f8184ecfa5df4a666a64792a97db0ecdc9d66.tar.gz src-233f8184ecfa5df4a666a64792a97db0ecdc9d66.zip |
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.
MFC after: 3 days
PR: 119079
Submitted by: Michael Plass <mfp49_freebsd@plass-family.net>
Notes
Notes:
svn path=/head/; revision=176895
Diffstat (limited to 'sys/ddb/db_input.c')
-rw-r--r-- | sys/ddb/db_input.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/ddb/db_input.c b/sys/ddb/db_input.c index b71324ec79ef..39f2da7bd908 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; |