File hostname.dif of Package lukemftp
--- src/ftp.c
+++ src/ftp.c
@@ -159,14 +159,15 @@
return (0);
}
- if (res0->ai_canonname)
- (void)strlcpy(hostnamebuf, res0->ai_canonname,
- sizeof(hostnamebuf));
- else
- (void)strlcpy(hostnamebuf, host, sizeof(hostnamebuf));
- hostname = hostnamebuf;
-
for (res = res0; res; res = res->ai_next) {
+
+ if (res->ai_canonname)
+ (void)strlcpy(hostnamebuf, res->ai_canonname,
+ sizeof(hostnamebuf));
+ else
+ (void)strlcpy(hostnamebuf, host, sizeof(hostnamebuf));
+ hostname = hostnamebuf;
+
/*
* make sure that ai_addr is NOT an IPv4 mapped address.
* IPv4 mapped address complicates too many things in FTP