Skip to content

Commit

Permalink
The usage of the insecure function gets is now gone. Instead fgets is…
Browse files Browse the repository at this point in the history
… used.
  • Loading branch information
omer committed Dec 3, 2017
1 parent e758612 commit 82b95fe
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand All @@ -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;
}

0 comments on commit 82b95fe

Please sign in to comment.