aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHarry Jeffery <harry@exec64.co.uk>2019-09-02 15:10:05 +0100
committerHarry Jeffery <harry@exec64.co.uk>2019-09-02 15:54:50 +0100
commit5bb3308d8b81b47f940f64b70efcaac91bde1755 (patch)
tree1790c89c304d7ad5cc2944e028a5d82bfd34bffa /src
parent42a15b157827dbd9c981416c8919ce5f5c907331 (diff)
downloadimv-5bb3308d8b81b47f940f64b70efcaac91bde1755.tar.gz
console: Don't allow newline/control characters to be typed
Diffstat (limited to 'src')
-rw-r--r--src/console.c6
1 files changed, 6 insertions, 0 deletions
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 <assert.h>
+#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <unicode/utext.h>
@@ -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;