summaryrefslogtreecommitdiff
path: root/input.c
diff options
context:
space:
mode:
authorOskar <[email protected]>2024-03-28 17:18:36 +0100
committerOskar <[email protected]>2024-03-28 17:18:36 +0100
commitccdda45af0c167e4db0b0f1e0b920fec388206a3 (patch)
tree618c9d620f9c951d40ab97946f0fbc292f87fa00 /input.c
parentf31f6cf866a50e659cc8fd1e847cc3ac5785e7e1 (diff)
added length check, its kinda bad not not tested
Diffstat (limited to 'input.c')
-rw-r--r--input.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/input.c b/input.c
index 9a8c91c..2cc2089 100644
--- a/input.c
+++ b/input.c
@@ -13,10 +13,21 @@ int smode_input(char *single, char **multiple, uint64_t focus) { // This functio
// char *single is for p, e, c, q, a
// char **multiple is for L, n, x and d. Although it can be expanded to be used in p and e.
- char smode_buf[SMODE_MAX_SIZE]; // Smode buffer
+ char smode_buf[SMODE_MAX_SIZE] = { '\0' }; // Smode buffer
fprintf(stdout, "(%lu): ", focus); // UI
fgets(smode_buf, SMODE_MAX_SIZE, stdin); // Read user input
+ int sbl = 0;
+ for ( ; sbl < SMODE_MAX_SIZE ; sbl++) {
+ if(smode_buf[sbl] == '\0') {
+ break;
+ }
+ }
+ if (sbl >= SMODE_MAX_INPUT_SIZE) {
+ fprintf(stderr, "sbl > SMODE_MAX_SIZE\n");
+ return _FAIL;
+ }
+
switch (smode_buf[0]) {
// from L to D there will be the 'Multiple' options. In their respective cases i will check if the input is valid or not.
// I will not make the program clean the input because that could lead to assumptions.