[PATCH 16/25] efi-stdio: limit set_cursor to screen size boundaries

Sascha Hauer s.hauer at pengutronix.de
Mon Dec 13 13:08:56 PST 2021


set_cursor_position() may only be called with values actually inside the
screen. Limit the values accordingly.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/serial/efi-stdio.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/serial/efi-stdio.c b/drivers/serial/efi-stdio.c
index dacdb74934..0ba8d3f6c0 100644
--- a/drivers/serial/efi-stdio.c
+++ b/drivers/serial/efi-stdio.c
@@ -244,8 +244,11 @@ static int efi_process_square_bracket(struct efi_console_priv *priv, const char
 		}
 		break;
 	case 'H':
-		if (arg0 >= 0 && arg1 >= 0)
-			priv->out->set_cursor_position(priv->out, arg1 - 1, arg0 - 1);
+		if (arg0 >= 0 && arg1 >= 0) {
+			int row = min_t(int, arg0, priv->rows);
+			int col = min_t(int, arg1, priv->columns);
+			priv->out->set_cursor_position(priv->out, col - 1, row - 1);
+		}
 		break;
 	case 'm':
 		switch (arg0) {
-- 
2.30.2




More information about the barebox mailing list