diff options
author | Mike Pechkin <mpech@cvs.openbsd.org> | 2001-07-31 14:32:16 +0000 |
---|---|---|
committer | Mike Pechkin <mpech@cvs.openbsd.org> | 2001-07-31 14:32:16 +0000 |
commit | 7e869dd08f73eb663a8c4425642b53a970c07585 (patch) | |
tree | a02a8c47bc41eb14abe73792f49caf39d68aaff9 /usr.bin/tftp | |
parent | 6486bc2f1faff9954cb6ccfa3cf8281947133020 (diff) |
o) better struct handling;
o) use __progname in openlog(3);
o) better ERROR packets handling;
millert@ ok
Diffstat (limited to 'usr.bin/tftp')
-rw-r--r-- | usr.bin/tftp/main.c | 14 | ||||
-rw-r--r-- | usr.bin/tftp/tftp.c | 11 |
2 files changed, 13 insertions, 12 deletions
diff --git a/usr.bin/tftp/main.c b/usr.bin/tftp/main.c index 35bb9ad673d..fc378f6039b 100644 --- a/usr.bin/tftp/main.c +++ b/usr.bin/tftp/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.7 2001/07/17 02:23:59 pvalchev Exp $ */ +/* $OpenBSD: main.c,v 1.8 2001/07/31 14:32:15 mpech Exp $ */ /* $NetBSD: main.c,v 1.6 1995/05/21 16:54:10 mycroft Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: main.c,v 1.7 2001/07/17 02:23:59 pvalchev Exp $"; +static char rcsid[] = "$OpenBSD: main.c,v 1.8 2001/07/31 14:32:15 mpech Exp $"; #endif /* not lint */ /* Many bug fixes are from Jim Guyton <guyton@rand-unix> */ @@ -149,7 +149,7 @@ struct cmd cmdtab[] = { { "rexmt", xhelp, setrexmt }, { "timeout", ihelp, settimeout }, { "?", hhelp, help }, - { 0 } + { NULL, NULL, NULL } }; struct cmd *getcmd(); @@ -245,7 +245,7 @@ struct modes { { "image", "octet" }, { "octet", "octet" }, /* { "mail", "mail" }, */ - { 0, 0 } + { NULL, NULL } }; void @@ -261,7 +261,7 @@ modecmd(argc, argv) return; } if (argc == 2) { - for (p = modes; p->m_name; p++) + for (p = modes; p->m_name != NULL; p++) if (strcmp(argv[1], p->m_name) == 0) break; if (p->m_name) { @@ -274,7 +274,7 @@ modecmd(argc, argv) printf("usage: %s [", argv[0]); sep = " "; - for (p = modes; p->m_name; p++) { + for (p = modes; p->m_name != NULL; p++) { printf("%s%s", sep, p->m_name); if (*sep == ' ') sep = " | "; @@ -710,7 +710,7 @@ help(argc, argv) if (argc == 1) { printf("Commands may be abbreviated. Commands are:\n\n"); - for (c = cmdtab; c->name; c++) + for (c = cmdtab; c->name != NULL; c++) printf("%-*s\t%s\n", (int)HELPINDENT, c->name, c->help); return; } diff --git a/usr.bin/tftp/tftp.c b/usr.bin/tftp/tftp.c index c03a88493e0..ffacababc29 100644 --- a/usr.bin/tftp/tftp.c +++ b/usr.bin/tftp/tftp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tftp.c,v 1.7 2001/03/22 01:34:01 mickey Exp $ */ +/* $OpenBSD: tftp.c,v 1.8 2001/07/31 14:32:15 mpech Exp $ */ /* $NetBSD: tftp.c,v 1.5 1995/04/29 05:55:25 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)tftp.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: tftp.c,v 1.7 2001/03/22 01:34:01 mickey Exp $"; +static char rcsid[] = "$OpenBSD: tftp.c,v 1.8 2001/07/31 14:32:15 mpech Exp $"; #endif /* not lint */ /* Many bug fixes are from Jim Guyton <guyton@rand-unix> */ @@ -336,7 +336,7 @@ struct errmsg { { EBADID, "Unknown transfer ID" }, { EEXISTS, "File already exists" }, { ENOUSER, "No such user" }, - { -1, 0 } + { -1, NULL } }; /* @@ -363,8 +363,9 @@ nak(error) pe->e_msg = strerror(error - 100); tp->th_code = EUNDEF; } - strcpy(tp->th_msg, pe->e_msg); - length = strlen(pe->e_msg) + 4; + length = strlcpy(tp->th_msg, pe->e_msg, sizeof(ackbuf)) + 5; + if (length > sizeof(ackbuf)) + length = sizeof(ackbuf); if (trace) tpacket("sent", tp, length); if (sendto(f, ackbuf, length, 0, (struct sockaddr *)&peeraddr, |