I just installed SSH version 2.4.0 on some of my UNIX hosts.  When I try to
connect to hostnames with multiple IP addresses, it fails with the error:

FATAL: Connecting to "hostname" failed: No address associated to the name

where "hostname" is the name of the cluster I'm trying to connect to.

I noticed a few other people have asked about this by doing a web search,
but never found an answer to the problem.

So, I took a look at the code, and found out what's going wrong.

In the routine ssh_tcp_get_host_addrs_by_name_sync, if a hostname has
multiple IP addresses, a comma is supposed to be inserted between the
addresses.  Unfortunately, the code to add that comma is two lines too
low, so addresses get concatenated together without a comma in the middle.
By moving the comma inserting loop above the address concatenating call,
the problem is fix.

I've included the tiny patch.  It's attached to this message.

If others have come up with a solution, great.  I just thought that I'd
share.

Should something like this be fed back to the folks at ssh.com?

mga.
--
Mike Austin                           Computing & Information Technology
Systems Programmer                    The University of Vermont
UNIX/DCE Sys Admin                    802-656-8785
diff -c -r ssh-2.4.0/lib/sshutil/sshnet/unix/sshunixtcp.c 
ssh-2.4.0-uvm/lib/sshutil/sshnet/unix/sshunixtcp.c
*** ssh-2.4.0/lib/sshutil/sshnet/unix/sshunixtcp.c      Tue Dec  5 11:16:08 2000
--- ssh-2.4.0-uvm/lib/sshutil/sshnet/unix/sshunixtcp.c  Thu Feb 22 11:26:53 2001
***************
*** 934,946 ****
            addr_len *= 2;
            addresses = ssh_xrealloc(addresses, addr_len);
          }
!       ssh_ipaddr_print(&ip, addresses + addr_ptr, addr_len - addr_ptr);
!       addr_ptr += strlen(addresses + addr_ptr);
        if (i > 0)
          {
            addresses[addr_ptr++] = ',';
            addresses[addr_ptr] = '\0';
          }
      }
    return addresses;
  #endif /* VXWORKS */
--- 934,950 ----
            addr_len *= 2;
            addresses = ssh_xrealloc(addresses, addr_len);
          }
! /* Moved "if (i > 0)" statement up two lines, so comma is added at
!  * the correct place for hostnames with multiple IP addresses.
!  * Mike Austin <[EMAIL PROTECTED]>
! */
        if (i > 0)
          {
            addresses[addr_ptr++] = ',';
            addresses[addr_ptr] = '\0';
          }
+       ssh_ipaddr_print(&ip, addresses + addr_ptr, addr_len - addr_ptr);
+       addr_ptr += strlen(addresses + addr_ptr);
      }
    return addresses;
  #endif /* VXWORKS */

Reply via email to