9
0
Fork 0

fbconsole: check cursor position before moving

Moving the cursor to x=2, y=2 with "\e[3;3H" on a 12x2 framebuffer
console lead to a barebox crash while drawing the cursor. If the
cursor position is out of bounds clip the cursor to the corresponding
edge.

Signed-off-by: Bastian Stender <bst@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Bastian Stender 2017-02-27 14:39:30 +01:00 committed by Sascha Hauer
parent 41c3c713c4
commit 1e2f65d72a
1 changed files with 5 additions and 2 deletions

View File

@ -264,10 +264,13 @@ static void fbc_parse_csi(struct fbc_priv *priv)
return;
case 'H':
video_invertchar(priv, priv->x, priv->y);
pos = simple_strtoul(priv->csi, &end, 10);
priv->y = pos ? pos - 1 : 0;
priv->y = clamp(pos - 1, 0, (int) priv->rows);
pos = simple_strtoul(end + 1, NULL, 10);
priv->x = pos ? pos - 1 : 0;
priv->x = clamp(pos - 1, 0, (int) priv->cols);
video_invertchar(priv, priv->x, priv->y);
case 'K':
pos = simple_strtoul(priv->csi, &end, 10);