From 5bb3308d8b81b47f940f64b70efcaac91bde1755 Mon Sep 17 00:00:00 2001 From: Harry Jeffery Date: Mon, 2 Sep 2019 15:10:05 +0100 Subject: console: Don't allow newline/control characters to be typed --- src/console.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/console.c b/src/console.c index 01b7925..9243e24 100644 --- a/src/console.c +++ b/src/console.c @@ -1,6 +1,7 @@ #include "console.h" #include +#include #include #include #include @@ -104,6 +105,11 @@ void imv_console_input(struct imv_console *console, const char *text) return; } + /* Don't allow newlines or control characters. */ + if (*text == '\n' || iscntrl(*text)) { + return; + } + /* Increase buffer size if needed */ if (strlen(text) + strlen(console->buffer) + 1 > console->buffer_len) { console->buffer_len *= 2; -- cgit v1.2.3