From 83fb285d401a68e87df85662dbba44b343edb6fd Mon Sep 17 00:00:00 2001 From: Gunter Knauf Date: Sat, 4 Jul 2009 01:04:23 +0000 Subject: [PATCH] Markus Koetter provided a patch to avoid getnameinfo() usage which broke a couple of both IPv4 and IPv6 autobuilds. --- CHANGES | 4 ++++ lib/ftp.c | 21 +++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/CHANGES b/CHANGES index 4eb548a49..36c7d7c51 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,10 @@ Changelog +Guenter Knauf (4 Jul 2009) +- Markus Koetter provided a patch to avoid getnameinfo() usage which broke a + couple of both IPv4 and IPv6 autobuilds. + Daniel Stenberg (29 Jun 2009) - Markus Koetter made CURLOPT_FTPPORT (and curl's -P/--ftpport) support a port range if given colon-separated after the host name/address part. Like diff --git a/lib/ftp.c b/lib/ftp.c index 59fc1157a..4c9bcd011 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -1000,22 +1000,23 @@ static CURLcode ftp_state_use_port(struct connectdata *conn, the IP from the control connection */ sslen = sizeof(ss); - if(getsockname(conn->sock[FIRSTSOCKET], (struct sockaddr *)&ss, &sslen)) { + if(getsockname(conn->sock[FIRSTSOCKET], sa, &sslen)) { failf(data, "getsockname() failed: %s", Curl_strerror(conn, SOCKERRNO) ); if (addr) free(addr); return CURLE_FTP_PORT_FAILED; } - - sslen = sizeof(ss); - rc = getnameinfo((struct sockaddr *)&ss, sslen, hbuf, sizeof(hbuf), NULL, - 0, NIFLAGS); - if(rc) { - failf(data, "getnameinfo() returned %d", rc); - if (addr) - free(addr); - return CURLE_FTP_PORT_FAILED; + switch(sa->sa_family) + { +#ifdef ENABLE_IPV6 + case AF_INET6: + Curl_inet_ntop(sa->sa_family, &sa6->sin6_addr, hbuf, sizeof(hbuf)); + break; +#endif + default: + Curl_inet_ntop(sa->sa_family, &sa4->sin_addr, hbuf, sizeof(hbuf)); + break; } host = hbuf; /* use this host name */ }