From e6e11ab4c6cceddb993fb4b1dda8f493f4e52b2c Mon Sep 17 00:00:00 2001 From: Marcus Glocker Date: Wed, 26 Jul 2006 22:43:54 +0000 Subject: Make tftp atoi() free. --- usr.bin/tftp/main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'usr.bin') 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); -- cgit v1.2.3