diff options
author | 2006-07-26 09:10:03 +0000 | |
---|---|---|
committer | 2006-07-26 09:10:03 +0000 | |
commit | af07602a0ab89550f75639cc7ee8148cfacd1dd4 (patch) | |
tree | fd64869484d454ab1caa4f39711e0d372ae9c187 /usr.bin/tftp/main.c | |
parent | Alpha boot has defaulted to multiuser for a long time, so better stop (diff) | |
download | wireguard-openbsd-af07602a0ab89550f75639cc7ee8148cfacd1dd4.tar.xz wireguard-openbsd-af07602a0ab89550f75639cc7ee8148cfacd1dd4.zip |
Fixing several timeout quirks at tftpd and tftp:
- move TIMEOUT* defines to arpa/tftp.h, as they are used several times
in tftpd and tftp, and the values are part of the RFC definition.
- tftpd and tftp did count the total retransmission time in retries
instead in seconds. fixed.
- tftpd rexmt timeout was hardcoded by a define and therefore didn't
changed when the timeout option was sent. fixed.
- limit total retransmission timeout in tftp to also 255 seconds.
- replace obvious atoi()'s by strtonum().
ok claudio@
Diffstat (limited to 'usr.bin/tftp/main.c')
-rw-r--r-- | usr.bin/tftp/main.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/usr.bin/tftp/main.c b/usr.bin/tftp/main.c index ce9d6ecb793..006a6601ecb 100644 --- a/usr.bin/tftp/main.c +++ b/usr.bin/tftp/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.26 2006/07/24 17:29:58 mglocker Exp $ */ +/* $OpenBSD: main.c,v 1.27 2006/07/26 09:10:03 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.26 2006/07/24 17:29:58 mglocker Exp $"; + "$OpenBSD: main.c,v 1.27 2006/07/26 09:10:03 mglocker Exp $"; #endif /* not lint */ /* @@ -71,7 +71,6 @@ static const char rcsid[] = #include "extern.h" -#define TIMEOUT 5 /* secs between rexmt's */ #define LBUFLEN 200 /* size of input buffer */ #define MAXARGV 20 #define HELPINDENT (sizeof("connect")) @@ -519,7 +518,7 @@ setrexmt(int argc, char *argv[]) printf("usage: %s value\n", argv[0]); return; } - t = strtonum(argv[1], 1, 255, &errstr); + t = strtonum(argv[1], TIMEOUT_MIN, TIMEOUT_MAX, &errstr); if (errstr) printf("%s: value is %s\n", argv[1], errstr); else @@ -529,7 +528,8 @@ setrexmt(int argc, char *argv[]) void settimeout(int argc, char *argv[]) { - int t; + int t; + const char *errstr; if (argc < 2) { strlcpy(line, "Maximum-timeout ", sizeof(line)); @@ -545,8 +545,9 @@ settimeout(int argc, char *argv[]) return; } t = atoi(argv[1]); - if (t < 0) - printf("%s: bad value\n", argv[1]); + t = strtonum(argv[1], TIMEOUT_MIN, TIMEOUT_MAX, &errstr); + if (errstr) + printf("%s: value is %s\n", argv[1], errstr); else maxtimeout = t; } |