]> git.baikalelectronics.ru Git - kernel.git/commit
tty vt: fix character insertion overflow
authorNicolas Pitre <nicolas.pitre@linaro.org>
Mon, 25 Feb 2013 01:06:09 +0000 (20:06 -0500)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 25 Feb 2013 01:29:49 +0000 (17:29 -0800)
commit1e576cb1476a8fa5b4a87e90213ee961c4be91ca
tree923e2b4d21eecff2561b02e841638ae82467e74c
parent3ce71ac5f71f32ba490386ba035d2f1ab55716f9
tty vt: fix character insertion overflow

Commit 0ca3f3241815 ("tty vt: Fix line garbage in virtual console on
command line edition") broke insert_char() in multiple ways.  Then
commit c04b153ae064 ("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>
drivers/tty/vt/vt.c