From 10f1f202b9e7ce2cb7eeedfc636439e3b1796510 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Sat, 27 Aug 2005 17:17:55 +0000 Subject: 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 . OK deraadt@ henning@ krw@ --- usr.bin/less/line.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'usr.bin/less/line.c') 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; } -- cgit v1.2.3