(hookup): handle ai_canonname being set in any of the addresses

returnedby getaddrinfo.  glibc apparently returns the reverse lookup
of every address in ai_canonname.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@7756 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
2000-01-08 07:43:47 +00:00
parent 80e917a6ec
commit 45d1cde80c

View File

@@ -76,10 +76,7 @@ hookup (const char *host, int port)
code = -1; code = -1;
return NULL; return NULL;
} }
if (ai->ai_canonname != NULL) strlcpy (hostnamebuf, host, sizeof(hostnamebuf));
strlcpy (hostnamebuf, ai->ai_canonname, sizeof(hostnamebuf));
else
strlcpy (hostnamebuf, host, sizeof(hostnamebuf));
hostname = hostnamebuf; hostname = hostnamebuf;
for (a = ai; a != NULL; a = a->ai_next) { for (a = ai; a != NULL; a = a->ai_next) {
@@ -87,6 +84,9 @@ hookup (const char *host, int port)
if (s < 0) if (s < 0)
continue; continue;
if (a->ai_canonname != NULL)
strlcpy (hostnamebuf, a->ai_canonname, sizeof(hostnamebuf));
memcpy (hisctladdr, a->ai_addr, a->ai_addrlen); memcpy (hisctladdr, a->ai_addr, a->ai_addrlen);
error = connect (s, a->ai_addr, a->ai_addrlen); error = connect (s, a->ai_addr, a->ai_addrlen);