From 43722f2591aaa6b93108f276555aa854440a914d Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sat, 19 Jul 2025 02:33:51 -0400 Subject: usr: osh: Only write printable characters Signed-off-by: Ian Moffett --- usr.bin/osh/osh.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'usr.bin') diff --git a/usr.bin/osh/osh.c b/usr.bin/osh/osh.c index af0ba3a..0f2108c 100644 --- a/usr.bin/osh/osh.c +++ b/usr.bin/osh/osh.c @@ -39,7 +39,9 @@ #include #include +#define is_printable(C) ((C) >= 32 && (C) <= 126) #define is_ascii(C) ((C) >= 0 && (C) <= 128) + #define COMMENT '@' #define WELCOME \ ":::::::::::::::::::::::::::::::::::::::\n" \ @@ -233,7 +235,7 @@ getstr(void) } else if (bell_fd > 0 && bs_bell) { write(bell_fd, &beep_payload, sizeof(beep_payload)); } - } else if (is_ascii(c) && buf_i < sizeof(buf) - 1) { + } else if (is_printable(c) && buf_i < sizeof(buf) - 1) { /* write to fd and add to buffer */ buf[buf_i++] = c; putchar(c); -- cgit v1.2.3