aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorNicolas Pitre <nicolas.pitre@linaro.org>2013-02-24 20:06:09 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-24 20:29:49 -0500
commita883b70d8e0a88278c0a1f80753b4dc99962b541 (patch)
tree923e2b4d21eecff2561b02e841638ae82467e74c /drivers/tty
parent77be36de8b07027a70fbc8f02703ccd76cd16d09 (diff)
tty vt: fix character insertion overflow
Commit 81732c3b2fed ("tty vt: Fix line garbage in virtual console on command line edition") broke insert_char() in multiple ways. Then commit b1a925f44a3a ("tty vt: Fix a regression in command line edition") partially fixed it. However, the buffer being moved is still too large and overflowing beyond the end of the current line, corrupting existing characters on the next line. Example test case: echo -e "abc\nde\x1b[A\x1b[4h \x1b[4l\x1b[B" Expected result: ab c de Current result: ab c e Needless to say that this is very annoying when inserting words in the middle of paragraphs with certain text editors. Signed-off-by: Nicolas Pitre <nico@linaro.org> Cc: Jean-François Moine <moinejf@free.fr> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: <stable@vger.kernel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/vt/vt.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 1a2728034599..6c4abeaf690f 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -539,7 +539,7 @@ static void insert_char(struct vc_data *vc, unsigned int nr)
539{ 539{
540 unsigned short *p = (unsigned short *) vc->vc_pos; 540 unsigned short *p = (unsigned short *) vc->vc_pos;
541 541
542 scr_memmovew(p + nr, p, (vc->vc_cols - vc->vc_x) * 2); 542 scr_memmovew(p + nr, p, (vc->vc_cols - vc->vc_x - nr) * 2);
543 scr_memsetw(p, vc->vc_video_erase_char, nr * 2); 543 scr_memsetw(p, vc->vc_video_erase_char, nr * 2);
544 vc->vc_need_wrap = 0; 544 vc->vc_need_wrap = 0;
545 if (DO_UPDATE(vc)) 545 if (DO_UPDATE(vc))