From 5215854c0ac8975b4821c26060e71f3645047da3 Mon Sep 17 00:00:00 2001 From: krakenlake Date: Sun, 9 Feb 2025 11:43:52 +0100 Subject: [PATCH] check cmdline input buffer for overrun --- src/main.S | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main.S b/src/main.S index 2900b29..5663bd9 100644 --- a/src/main.S +++ b/src/main.S @@ -118,7 +118,15 @@ main_get_char: jal uart_wait_get_char li t0, ASCII_DELETE beq a0, t0, is_delete + # char is not DELETE + # check if end of input buffer is reached + la t0, buffer + addi t0, t0, BUFFER_SIZE + # do not process input further when buffer is full + # (only possible user action when buffer is full will be to hit DELETE) + bge s3, t0, main_get_char + sb a0, 0(s3) # store byte in input buffer addi s3, s3, 1 # inc buffer ptr j continue_not_delete