summaryrefslogtreecommitdiffstats
path: root/drivers/serial
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2021-12-09 16:40:40 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2021-12-13 23:37:32 +0100
commita6f2d7f4ace14abbfeb2fd297f56932f55fd221d (patch)
treec88fcc1b0c362ee998bf02581a45aa7e6d6ef32e /drivers/serial
parent5c1fdc96a571597778836f64cd778d5eaded3899 (diff)
downloadbarebox-a6f2d7f4ace14abbfeb2fd297f56932f55fd221d.tar.gz
barebox-a6f2d7f4ace14abbfeb2fd297f56932f55fd221d.tar.xz
efi-stdio: fix escape sequence end detection
So far we only correctly parse the escape sequence we know. Detect the possible end characters of the escape sequence upfront so that we at least consume the correct number of character, eventhough the escape sequence might be unknown and ignored. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/serial')
-rw-r--r--drivers/serial/efi-stdio.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/drivers/serial/efi-stdio.c b/drivers/serial/efi-stdio.c
index f8cb37af56..dc1b45340c 100644
--- a/drivers/serial/efi-stdio.c
+++ b/drivers/serial/efi-stdio.c
@@ -138,10 +138,17 @@ static int efi_process_square_bracket(struct efi_console_priv *priv, const char
{
int x, y;
char *endp;
+ int retlen;
+
+ endp = strpbrk(inp, "ABCDEFGHJKmr");
+ if (!endp)
+ return 0;
+
+ retlen = endp - inp + 1;
inp++;
- switch (*inp) {
+ switch (*endp) {
case 'A':
/* Cursor up */
case 'B':
@@ -154,27 +161,27 @@ static int efi_process_square_bracket(struct efi_console_priv *priv, const char
/* home */
case 'F':
/* end */
- return 2;
+ return retlen;
case 'K':
clear_to_eol(priv);
- return 2;
+ return retlen;
}
if (*inp == '2' && *(inp + 1) == 'J') {
priv->out->clear_screen(priv->out);
- return 3;
+ return retlen;
}
if (*inp == '0' && *(inp + 1) == 'm') {
priv->out->set_attribute(priv->out,
EFI_TEXT_ATTR(EFI_WHITE, EFI_BLACK));
- return 3;
+ return retlen;
}
if (*inp == '7' && *(inp + 1) == 'm') {
priv->out->set_attribute(priv->out,
EFI_TEXT_ATTR(EFI_BLACK, priv->current_color));
- return 3;
+ return retlen;
}
if (*inp == '1' &&
@@ -198,7 +205,7 @@ static int efi_process_square_bracket(struct efi_console_priv *priv, const char
priv->out->set_attribute(priv->out,
EFI_TEXT_ATTR(color, EFI_BLACK));
- return 6;
+ return retlen;
}
y = simple_strtoul(inp, &endp, 10);
@@ -206,11 +213,11 @@ static int efi_process_square_bracket(struct efi_console_priv *priv, const char
x = simple_strtoul(endp + 1, &endp, 10);
if (*endp == 'H') {
priv->out->set_cursor_position(priv->out, x - 1, y - 1);
- return endp - inp + 2;
+ return retlen;
}
}
- return 7;
+ return retlen;
}
static int efi_process_escape(struct efi_console_priv *priv, const char *inp)