From 3462827e805ec16627015480579b84adc1709314 Mon Sep 17 00:00:00 2001 From: Assar Westerlund Date: Sat, 8 Jan 2000 07:45:11 +0000 Subject: [PATCH] (guess_domain): 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@7757 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/ftp/ftp/ruserpass.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/appl/ftp/ftp/ruserpass.c b/appl/ftp/ftp/ruserpass.c index 36865b124..f42366c16 100644 --- a/appl/ftp/ftp/ruserpass.c +++ b/appl/ftp/ftp/ruserpass.c @@ -71,7 +71,7 @@ static struct toktab { static char * guess_domain (char *hostname, size_t sz) { - struct addrinfo *ai; + struct addrinfo *ai, *a; struct addrinfo hints; int error; char *dot; @@ -91,8 +91,11 @@ guess_domain (char *hostname, size_t sz) if (error) return hostname; - if (ai->ai_canonname != NULL) - strlcpy (hostname, ai->ai_canonname, sz); + for (a = ai; a != NULL; a = a->ai_next) + if (a->ai_canonname != NULL) { + strlcpy (hostname, ai->ai_canonname, sz); + break; + } freeaddrinfo (ai); dot = strchr (hostname, '.'); if (dot != NULL) -- 2.11.4.GIT