[BACK]Return to sshconnect.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/sshconnect.c between version 1.289 and 1.290

version 1.289, 2017/12/06 05:06:21 version 1.290, 2018/01/23 05:17:04
Line 404 
Line 404 
     int connection_attempts, int *timeout_ms, int want_keepalive, int needpriv)      int connection_attempts, int *timeout_ms, int want_keepalive, int needpriv)
 {  {
         int on = 1;          int on = 1;
         int sock = -1, attempt;          int oerrno, sock = -1, attempt;
         char ntop[NI_MAXHOST], strport[NI_MAXSERV];          char ntop[NI_MAXHOST], strport[NI_MAXSERV];
         struct addrinfo *ai;          struct addrinfo *ai;
   
Line 424 
Line 424 
                  */                   */
                 for (ai = aitop; ai; ai = ai->ai_next) {                  for (ai = aitop; ai; ai = ai->ai_next) {
                         if (ai->ai_family != AF_INET &&                          if (ai->ai_family != AF_INET &&
                             ai->ai_family != AF_INET6)                              ai->ai_family != AF_INET6) {
                                   errno = EAFNOSUPPORT;
                                 continue;                                  continue;
                           }
                         if (getnameinfo(ai->ai_addr, ai->ai_addrlen,                          if (getnameinfo(ai->ai_addr, ai->ai_addrlen,
                             ntop, sizeof(ntop), strport, sizeof(strport),                              ntop, sizeof(ntop), strport, sizeof(strport),
                             NI_NUMERICHOST|NI_NUMERICSERV) != 0) {                              NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
                                   oerrno = errno;
                                 error("%s: getnameinfo failed", __func__);                                  error("%s: getnameinfo failed", __func__);
                                   errno = oerrno;
                                 continue;                                  continue;
                         }                          }
                         debug("Connecting to %.200s [%.100s] port %s.",                          debug("Connecting to %.200s [%.100s] port %s.",
Line 439 
Line 443 
                         sock = ssh_create_socket(needpriv, ai);                          sock = ssh_create_socket(needpriv, ai);
                         if (sock < 0)                          if (sock < 0)
                                 /* Any error is already output */                                  /* Any error is already output */
                                   errno = 0;
                                 continue;                                  continue;
   
                         if (timeout_connect(sock, ai->ai_addr, ai->ai_addrlen,                          if (timeout_connect(sock, ai->ai_addr, ai->ai_addrlen,
Line 447 
Line 452 
                                 memcpy(hostaddr, ai->ai_addr, ai->ai_addrlen);                                  memcpy(hostaddr, ai->ai_addr, ai->ai_addrlen);
                                 break;                                  break;
                         } else {                          } else {
                                   oerrno = errno;
                                 debug("connect to address %s port %s: %s",                                  debug("connect to address %s port %s: %s",
                                     ntop, strport, strerror(errno));                                      ntop, strport, strerror(errno));
                                 close(sock);                                  close(sock);
                                 sock = -1;                                  sock = -1;
                                   errno = oerrno;
                         }                          }
                 }                  }
                 if (sock != -1)                  if (sock != -1)
Line 460 
Line 467 
         /* Return failure if we didn't get a successful connection. */          /* Return failure if we didn't get a successful connection. */
         if (sock == -1) {          if (sock == -1) {
                 error("ssh: connect to host %s port %s: %s",                  error("ssh: connect to host %s port %s: %s",
                     host, strport, strerror(errno));                      host, strport, errno == 0 ? "failure" : strerror(errno));
                 return (-1);                  return -1;
         }          }
   
         debug("Connection established.");          debug("Connection established.");

Legend:
Removed from v.1.289  
changed lines
  Added in v.1.290