diff options
author | Marcus Glocker <mglocker@cvs.openbsd.org> | 2006-07-26 09:10:04 +0000 |
---|---|---|
committer | Marcus Glocker <mglocker@cvs.openbsd.org> | 2006-07-26 09:10:04 +0000 |
commit | 04acdec08de4742e5f76c09ebb6db4bc0990046b (patch) | |
tree | 2b837323f12d00b831d95f3b510d141dd4dcfca8 /usr.bin/tftp/tftp.c | |
parent | 3667d73033cf93032bbbafed056c205a4eea65db (diff) |
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/tftp.c')
-rw-r--r-- | usr.bin/tftp/tftp.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/usr.bin/tftp/tftp.c b/usr.bin/tftp/tftp.c index 9c817990407..3638b2731fe 100644 --- a/usr.bin/tftp/tftp.c +++ b/usr.bin/tftp/tftp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tftp.c,v 1.19 2006/07/24 17:29:58 mglocker Exp $ */ +/* $OpenBSD: tftp.c,v 1.20 2006/07/26 09:10:03 mglocker Exp $ */ /* $NetBSD: tftp.c,v 1.5 1995/04/29 05:55:25 cgd Exp $ */ /* @@ -35,7 +35,7 @@ static char sccsid[] = "@(#)tftp.c 8.1 (Berkeley) 6/6/93"; #endif static const char rcsid[] = - "$OpenBSD: tftp.c,v 1.19 2006/07/24 17:29:58 mglocker Exp $"; + "$OpenBSD: tftp.c,v 1.20 2006/07/26 09:10:03 mglocker Exp $"; #endif /* not lint */ /* @@ -162,7 +162,7 @@ sendfile(int fd, char *name, char *mode) /* send data to server and wait for server ACK */ for (timeouts = 0, error = 0; !intrflag;) { - if (timeouts == maxtimeout) { + if (timeouts >= maxtimeout) { printtimeout(); goto abort; } @@ -185,7 +185,7 @@ sendfile(int fd, char *name, char *mode) pfd[0].events = POLLIN; nfds = poll(pfd, 1, rexmtval * 1000); if (nfds == 0) { - timeouts++; + timeouts += rexmtval; continue; } if (nfds == -1) { @@ -295,7 +295,7 @@ options: /* send ACK to server and wait for server data */ for (timeouts = 0, error = 0; !intrflag;) { - if (timeouts == maxtimeout) { + if (timeouts >= maxtimeout) { printtimeout(); goto abort; } @@ -317,7 +317,7 @@ options: pfd[0].events = POLLIN; nfds = poll(pfd, 1, rexmtval * 1000); if (nfds == 0) { - timeouts++; + timeouts += rexmtval; continue; } if (nfds == -1) { @@ -602,7 +602,8 @@ oack_set(const char *option, const char *value) } if (i == OPT_TIMEOUT) { /* verify OACK response */ - n = strtonum(value, 1, 255, &errstr); + n = strtonum(value, TIMEOUT_MIN, TIMEOUT_MAX, + &errstr); if (errstr || rexmtval != n || opt_tout == 0) { nak(EOPTNEG); |