qemu-e2k/ui
Gerd Hoffmann 5b8541c6c7 console: fix cell overflow
Linux terminal behavior (coming from vt100 I think) is somewhat strange
when it comes to line wraps:  When a character is printed to the last
char cell of a line the cursor does NOT jump to the next line but stays
where it is.  The line feed happens when the next character is printed.

So the valid range for the cursor position is not 0 .. width-1 but
0 .. width, where x == width represents the state where the line is
full but the cursor didn't jump to the next line yet.

The code for the 'clear from start of line' control sequence (ESC[1K)
fails to handle this corner case correctly and may call
console_clear_xy() with x == width.  That will incorrectly clear the
first char cell of the next line, or in case the cursor happens to be on
the last line overflow the cell buffer by one character (three bytes).

Add a check to the loop to fix that.

Didn't spot any other places with the same problem.  But it's easy to
miss that corner case, so also allocate one extra cell as precaution, so
in case we have simliar issues lurking elsewhere it at least wouldn't be
a buffer overflow.

v2: squashed in additional checks suggested by Christophe de Dinechin.

Reported-by: Alexander Oleinik <alxndr@bu.edu>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Christophe de Dinechin <dinechin@redhat.com>
Message-id: 20190701075301.14165-1-kraxel@redhat.com
2019-07-03 10:57:12 +02:00
..
icons
keycodemapdb@6b3d716e2b
shader
cocoa.m ui/cocoa: Fix mouse grabbing in fullscreen mode for relative input device 2019-06-13 11:23:22 +01:00
console-gl.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
console.c console: fix cell overflow 2019-07-03 10:57:12 +02:00
curses_keys.h
curses.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
cursor_hidden.xpm
cursor_left_ptr.xpm
cursor.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
egl-context.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
egl-headless.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
egl-helpers.c egl-helpers: add modifier support to egl_dmabuf_import_texture() 2019-06-07 11:52:35 +02:00
gtk-egl.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
gtk-gl-area.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
gtk.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
input-keymap.c
input-legacy.c
input-linux.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
input.c
kbd-state.c kbd-state: fix autorepeat handling 2019-05-17 13:21:40 +02:00
keymaps.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
keymaps.h Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
Makefile.objs
qemu-pixman.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
qemu-x509.h
qemu.desktop
sdl2-2d.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
sdl2-gl.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
sdl2-input.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
sdl2.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
shader.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
spice-app.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
spice-core.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
spice-display.c egl-helpers: add modifier support to egl_get_fd_for_texture(). 2019-06-07 11:52:35 +02:00
spice-input.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
trace-events
vgafont.h
vnc_keysym.h
vnc-auth-sasl.c
vnc-auth-sasl.h
vnc-auth-vencrypt.c
vnc-auth-vencrypt.h
vnc-enc-hextile-template.h
vnc-enc-hextile.c
vnc-enc-tight.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
vnc-enc-tight.h
vnc-enc-zlib.c
vnc-enc-zrle.c
vnc-enc-zrle.h
vnc-enc-zrle.inc.c
vnc-enc-zywrle-template.c
vnc-enc-zywrle.h
vnc-jobs.c
vnc-jobs.h
vnc-palette.c
vnc-palette.h
vnc-stubs.c
vnc-ws.c
vnc-ws.h
vnc.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
vnc.h Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
x_keymap.c
x_keymap.h