From 0ea0f8bf579da9ce9c61f941598983d81f3d5cde Mon Sep 17 00:00:00 2001 From: Oskar Date: Thu, 4 Apr 2024 22:29:27 +0200 Subject: Some fixes for the 'single' inputs. Now only allows for single characters and NOTHING more --- input.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/input.c b/input.c index 41ff0f5..a86ec4c 100644 --- a/input.c +++ b/input.c @@ -12,6 +12,27 @@ int clfstdin_doubleprint = 1; // variable accessed via extern int in startmode s int check_length_fix_stdin(char *smode_buf) { + int not_newline = 1; + switch (smode_buf[0]) { // This whole thing just checks for 'single' inputs. The single inputs can ONLY and should only allow for single characters. + case 'p': + case 'P': + case 'e': + case 'E': + case 'c': + case 'C': + case 'q': + case 'Q': + case 'a': + case 'A': + if (smode_buf[1] != '\n') { // If not a new line + not_newline = 0; + break; + } else { + return 0; + } + break; + } + int sbl = 0; for ( ; sbl < SMODE_MAX_INPUT_SIZE ; sbl++) { if(smode_buf[sbl] == '\0' || smode_buf[sbl] == '\n') { @@ -27,6 +48,10 @@ int check_length_fix_stdin(char *smode_buf) { return _FAIL; } + if (not_newline == 0) { + return _FAIL; + } + return 0; } -- cgit v1.2.3