summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-05-26 21:38:18 -0400
committerIan Moffett <ian@osmora.org>2025-05-26 21:38:18 -0400
commit978dfa5e02acfcc35b9f31b9c88255c79ebcfb54 (patch)
treeb781519f8a8ee26fec5cb45e125959944707aa57
parent5fb5b80ca4aed97ef01858bfc19a9e752dd25e83 (diff)
kernel: cons: Fix newline caused by excessive '\b'
Before this commit, if you were to write out too many backspace characters, it would result in an integer underflow for the scr->curs_col and scr->ch_col state resulting in the console logic assuming the cursor has gone too far off the screen which would cause behavior similar to as if you wrote out a line-feed character. Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r--sys/dev/cons/cons.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/dev/cons/cons.c b/sys/dev/cons/cons.c
index bcd19bf..61254a7 100644
--- a/sys/dev/cons/cons.c
+++ b/sys/dev/cons/cons.c
@@ -165,8 +165,10 @@ cons_handle_special(struct cons_screen *scr, char c)
}
HIDE_CURSOR(scr);
- --scr->ch_col;
- --scr->curs_col;
+ if (scr->ch_col > 0 && scr->curs_col > 0) {
+ --scr->ch_col;
+ --scr->curs_col;
+ }
SHOW_CURSOR(scr);
return 0;
case ASCII_LF: