Description: ssh(1): Fix bad interaction between the ssh_config ConnectTimeout and ConnectionAttempts directives Connection attempts after the first were ignoring the requested timeout Origin: upstream, https://bugzilla.mindrot.org/attachment.cgi?id=3233 Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=2918 Forwarded: no Last-Update: 2023-03-29 --- a/sshconnect.c +++ b/sshconnect.c @@ -500,7 +500,7 @@ struct sockaddr_storage *hostaddr, u_short port, int family, int connection_attempts, int *timeout_ms, int want_keepalive) { - int on = 1; + int on = 1, saved_timeout_ms = *timeout_ms; int oerrno, sock = -1, attempt; char ntop[NI_MAXHOST], strport[NI_MAXSERV]; struct addrinfo *ai; @@ -544,6 +544,7 @@ continue; } + *timeout_ms = saved_timeout_ms; if (timeout_connect(sock, ai->ai_addr, ai->ai_addrlen, timeout_ms) >= 0) { /* Successful connection. */