From 82b95feef79cf39831b48ad5156d0c4e3aeb74e4 Mon Sep 17 00:00:00 2001 From: omer Date: Sun, 3 Dec 2017 20:41:50 +0100 Subject: [PATCH] The usage of the insecure function gets is now gone. Instead fgets is used. --- cli.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cli.c b/cli.c index beea414..98ebe45 100644 --- a/cli.c +++ b/cli.c @@ -174,7 +174,8 @@ int main(void) getcwd(cwd, BUFSIZE); printf("cli:%s%% ", (cwd == NULL) ? "" : cwd); - gets(buf); + fgets(buf, BUFSIZE, stdin); + if (strlen(buf) == 0) continue; if (strncmp(buf, "rm", 2) == 0 && !isalnum(buf[2])) @@ -196,7 +197,7 @@ int main(void) else printf("cli: not a valid command.\n" "type 'help' for a list of options\n\n"); - } while (strcmp(buf, "exit") != 0); + } while (strcmp(buf, "exit\n") != 0); return 0; }