summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBastian Stender <bst@pengutronix.de>2017-02-27 14:39:30 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2017-02-28 07:44:59 +0100
commit1e2f65d72a66da459227d5fdc165b2f02ce7f186 (patch)
treeeb1cfb9e1e9a6e7bab9562d3b9ac5d58892480d9
parent41c3c713c4ddbf44d89076257f0dd9ec94858b88 (diff)
downloadbarebox-1e2f65d72a66da459227d5fdc165b2f02ce7f186.tar.gz
barebox-1e2f65d72a66da459227d5fdc165b2f02ce7f186.tar.xz
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>
-rw-r--r--drivers/video/fbconsole.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/video/fbconsole.c b/drivers/video/fbconsole.c
index 693c21f547..598ca29282 100644
--- a/drivers/video/fbconsole.c
+++ b/drivers/video/fbconsole.c
@@ -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);