summaryrefslogtreecommitdiffstats
path: root/usr.bin/tftp/main.c
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>1995-12-27 23:23:43 +0000
committerjoerg <joerg@FreeBSD.org>1995-12-27 23:23:43 +0000
commit10ec2134d515a7192fc4b0b9192a41d3c9a43495 (patch)
tree1493952108a1ffb9c606e50e573908b5389cb4f5 /usr.bin/tftp/main.c
parent25337fa305e27d6e854af20ac2dda605fd8915e2 (diff)
downloadFreeBSD-src-10ec2134d515a7192fc4b0b9192a41d3c9a43495.zip
FreeBSD-src-10ec2134d515a7192fc4b0b9192a41d3c9a43495.tar.gz
Kill the (hopefully) last occurance of gets(3) in the base source tree.
Diffstat (limited to 'usr.bin/tftp/main.c')
-rw-r--r--usr.bin/tftp/main.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/usr.bin/tftp/main.c b/usr.bin/tftp/main.c
index c69195d..b34ab2c 100644
--- a/usr.bin/tftp/main.c
+++ b/usr.bin/tftp/main.c
@@ -195,7 +195,7 @@ setpeer(argc, argv)
if (argc < 2) {
strcpy(line, "Connect ");
printf("(to) ");
- gets(&line[strlen(line)]);
+ fgets(&line[strlen(line)], sizeof line - strlen(line), stdin);
makeargv();
argc = margc;
argv = margv;
@@ -323,7 +323,7 @@ put(argc, argv)
if (argc < 2) {
strcpy(line, "send ");
printf("(file) ");
- gets(&line[strlen(line)]);
+ fgets(&line[strlen(line)], sizeof line - strlen(line), stdin);
makeargv();
argc = margc;
argv = margv;
@@ -417,7 +417,7 @@ get(argc, argv)
if (argc < 2) {
strcpy(line, "get ");
printf("(files) ");
- gets(&line[strlen(line)]);
+ fgets(&line[strlen(line)], sizeof line - strlen(line), stdin);
makeargv();
argc = margc;
argv = margv;
@@ -501,7 +501,7 @@ setrexmt(argc, argv)
if (argc < 2) {
strcpy(line, "Rexmt-timeout ");
printf("(value) ");
- gets(&line[strlen(line)]);
+ fgets(&line[strlen(line)], sizeof line - strlen(line), stdin);
makeargv();
argc = margc;
argv = margv;
@@ -529,7 +529,7 @@ settimeout(argc, argv)
if (argc < 2) {
strcpy(line, "Maximum-timeout ");
printf("(value) ");
- gets(&line[strlen(line)]);
+ fgets(&line[strlen(line)], sizeof line - strlen(line), stdin);
makeargv();
argc = margc;
argv = margv;
@@ -593,16 +593,19 @@ static __dead void
command()
{
register struct cmd *c;
+ char *cp;
for (;;) {
printf("%s> ", prompt);
- if (gets(line) == 0) {
+ if (fgets(line, sizeof line , stdin) == 0) {
if (feof(stdin)) {
exit(0);
} else {
continue;
}
}
+ if ((cp = strchr(line, '\n')))
+ *cp = '\0';
if (line[0] == 0)
continue;
makeargv();
@@ -660,6 +663,8 @@ makeargv()
register char **argp = margv;
margc = 0;
+ if ((cp = strchr(line, '\n')))
+ *cp = '\0';
for (cp = line; *cp;) {
while (isspace(*cp))
cp++;
OpenPOWER on IntegriCloud