From 4e6a9f287eadd77e0198a73d98db5c9fa149c7d1 Mon Sep 17 00:00:00 2001 From: Daniel Belz Date: Fri, 17 Dec 2021 11:45:57 -0800 Subject: tftp: set timeout based on the connect-timeout parameter --- lib/tftp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/tftp.c b/lib/tftp.c index f8c68441c..240bf40e8 100644 --- a/lib/tftp.c +++ b/lib/tftp.c @@ -136,6 +136,7 @@ struct tftp_state_data { int rbytes; int sbytes; int blksize; + int option_timeout; int requested_blksize; unsigned short block; struct tftp_packet rpacket; @@ -222,6 +223,9 @@ static CURLcode tftp_set_timeouts(struct tftp_state_data *state) /* Set per-block timeout to total */ timeout = maxtime; + if(start) + state->option_timeout = (timeout > 255) ? 255 : (int)timeout; + /* Average reposting an ACK after 5 seconds */ state->retry_max = (int)timeout/5; @@ -507,7 +511,7 @@ static CURLcode tftp_send_first(struct tftp_state_data *state, (char *)state->spacket.data + sbytes, buf); /* add timeout option */ - msnprintf(buf, sizeof(buf), "%d", state->retry_time); + msnprintf(buf, sizeof(buf), "%d", state->option_timeout); if(result == CURLE_OK) result = tftp_option_add(state, &sbytes, (char *)state->spacket.data + sbytes, -- cgit v1.2.1