summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2005-08-27 17:17:55 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2005-08-27 17:17:55 +0000
commit10f1f202b9e7ce2cb7eeedfc636439e3b1796510 (patch)
tree04e25a838a08f04760d2393db87167005c6a084b /usr.bin
parentc45ecba5055f0edaeb54e4da9e9902e1961d7b8d (diff)
Fix off-by-one when moving a line to the end of the buffer. Instead
of doing our own memmove() (incorrectly) just use memmove(). Bug found by Matthias Scheler <tron@zhadum.de>. OK deraadt@ henning@ krw@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/less/line.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/usr.bin/less/line.c b/usr.bin/less/line.c
index 07858120eb0..bd82f504c20 100644
--- a/usr.bin/less/line.c
+++ b/usr.bin/less/line.c
@@ -895,8 +895,6 @@ back_raw_line(curr_pos, linep)
if (n <= 0)
{
int old_size_linebuf = size_linebuf;
- char *fm;
- char *to;
if (expand_linebuf())
{
/*
@@ -909,11 +907,8 @@ back_raw_line(curr_pos, linep)
/*
* Shift the data to the end of the new linebuf.
*/
- for (fm = linebuf + old_size_linebuf,
- to = linebuf + size_linebuf;
- fm >= linebuf; fm--, to--)
- *to = *fm;
n = size_linebuf - old_size_linebuf;
+ memmove(linebuf + n, linebuf, old_size_linebuf);
}
linebuf[--n] = c;
}