summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-07-19 02:33:51 -0400
committerIan Moffett <ian@osmora.org>2025-07-19 02:33:51 -0400
commit43722f2591aaa6b93108f276555aa854440a914d (patch)
treed859a235b22edca07453e29cd644ed77dbf07767
parent031217715fdd68556ffab79e9b898d9f8f80f035 (diff)
usr: osh: Only write printable characters
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r--usr.bin/osh/osh.c4
1 files changed, 3 insertions, 1 deletions
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 <string.h>
#include <stdio.h>
+#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);