summaryrefslogtreecommitdiffstats
path: root/usr.bin/tftp/main.c
diff options
context:
space:
mode:
authormglocker <mglocker@openbsd.org>2006-07-26 22:43:53 +0000
committermglocker <mglocker@openbsd.org>2006-07-26 22:43:53 +0000
commit2e6729bfc0e5597ee466f4b64d9fa050cab05624 (patch)
tree4afe34a8629a46f9952aa68b0d3cb50ba721885b /usr.bin/tftp/main.c
parent3.9 -> 4.0 sync (diff)
downloadwireguard-openbsd-2e6729bfc0e5597ee466f4b64d9fa050cab05624.tar.xz
wireguard-openbsd-2e6729bfc0e5597ee466f4b64d9fa050cab05624.zip
Make tftp atoi() free.
Diffstat (limited to 'usr.bin/tftp/main.c')
-rw-r--r--usr.bin/tftp/main.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/usr.bin/tftp/main.c b/usr.bin/tftp/main.c
index 006a6601ecb..33c6009c215 100644
--- a/usr.bin/tftp/main.c
+++ b/usr.bin/tftp/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.27 2006/07/26 09:10:03 mglocker Exp $ */
+/* $OpenBSD: main.c,v 1.28 2006/07/26 22:43:53 mglocker Exp $ */
/* $NetBSD: main.c,v 1.6 1995/05/21 16:54:10 mycroft Exp $ */
/*
@@ -41,7 +41,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
- "$OpenBSD: main.c,v 1.27 2006/07/26 09:10:03 mglocker Exp $";
+ "$OpenBSD: main.c,v 1.28 2006/07/26 22:43:53 mglocker Exp $";
#endif /* not lint */
/*
@@ -222,6 +222,7 @@ void
setpeer(int argc, char *argv[])
{
struct hostent *host;
+ const char *errstr;
if (argc < 2) {
strlcpy(line, "Connect ", sizeof(line));
@@ -253,9 +254,9 @@ setpeer(int argc, char *argv[])
}
port = sp->s_port;
if (argc == 3) {
- port = atoi(argv[2]);
- if (port < 0) {
- printf("%s: bad port number\n", argv[2]);
+ port = strtonum(argv[2], 1, 65535, &errstr);
+ if (errstr) {
+ printf("%s: port number is %s\n", argv[2], errstr);
connected = 0;
return;
}
@@ -544,7 +545,6 @@ settimeout(int argc, char *argv[])
printf("usage: %s value\n", argv[0]);
return;
}
- t = atoi(argv[1]);
t = strtonum(argv[1], TIMEOUT_MIN, TIMEOUT_MAX, &errstr);
if (errstr)
printf("%s: value is %s\n", argv[1], errstr);