summaryrefslogtreecommitdiff
path: root/Utilities/cmcurl/lib/hostip6.c
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-08-03 14:26:53 -0400
committerBrad King <brad.king@kitware.com>2016-08-03 14:26:53 -0400
commitf53f4a8a2d215dac634effea575a27e000dfcb29 (patch)
tree5782e71da9e12ab6081e47f8eaf8eeb908e1428a /Utilities/cmcurl/lib/hostip6.c
parente1c11352f231ae310339cd539ed59cb302bd4dbe (diff)
parent202adcfe056681109fe61569ecdb3bd69f0b4f97 (diff)
downloadcmake-f53f4a8a2d215dac634effea575a27e000dfcb29.tar.gz
Merge branch 'upstream-curl' into update-curl
* upstream-curl: curl 2016-08-03 (f2cb3a01)
Diffstat (limited to 'Utilities/cmcurl/lib/hostip6.c')
-rw-r--r--Utilities/cmcurl/lib/hostip6.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/Utilities/cmcurl/lib/hostip6.c b/Utilities/cmcurl/lib/hostip6.c
index 6ab131a8cb..4ebfc2dcfa 100644
--- a/Utilities/cmcurl/lib/hostip6.c
+++ b/Utilities/cmcurl/lib/hostip6.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at http://curl.haxx.se/docs/copyright.html.
+ * are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -49,9 +49,9 @@
#include "url.h"
#include "inet_pton.h"
#include "connect.h"
+/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
-/* The last #include file should be: */
#include "memdebug.h"
/***********************************************************************
@@ -59,7 +59,6 @@
**********************************************************************/
#ifdef CURLRES_IPV6
-
#if defined(CURLDEBUG) && defined(HAVE_GETNAMEINFO)
/* These are strictly for memory tracing and are using the same style as the
* family otherwise present in memdebug.c. I put these ones here since they
@@ -124,6 +123,7 @@ bool Curl_ipvalid(struct connectdata *conn)
{
if(conn->ip_version == CURL_IPRESOLVE_V6)
return Curl_ipv6works();
+
return TRUE;
}
@@ -167,15 +167,17 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
int error;
char sbuf[12];
char *sbufptr = NULL;
+#ifndef USE_RESOLVE_ON_IPS
char addrbuf[128];
+#endif
int pf;
- struct SessionHandle *data = conn->data;
+#if !defined(CURL_DISABLE_VERBOSE_STRINGS)
+ struct Curl_easy *data = conn->data;
+#endif
*waitp = 0; /* synchronous response only */
- /*
- * Check if a limited name resolve has been requested.
- */
+ /* Check if a limited name resolve has been requested */
switch(conn->ip_version) {
case CURL_IPRESOLVE_V4:
pf = PF_INET;
@@ -196,26 +198,37 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
hints.ai_family = pf;
hints.ai_socktype = conn->socktype;
+#ifndef USE_RESOLVE_ON_IPS
+ /*
+ * The AI_NUMERICHOST must not be set to get synthesized IPv6 address from
+ * an IPv4 address on iOS and Mac OS X.
+ */
if((1 == Curl_inet_pton(AF_INET, hostname, addrbuf)) ||
(1 == Curl_inet_pton(AF_INET6, hostname, addrbuf))) {
/* the given address is numerical only, prevent a reverse lookup */
hints.ai_flags = AI_NUMERICHOST;
}
+#endif
if(port) {
snprintf(sbuf, sizeof(sbuf), "%d", port);
sbufptr=sbuf;
}
+
error = Curl_getaddrinfo_ex(hostname, sbufptr, &hints, &res);
if(error) {
infof(data, "getaddrinfo(3) failed for %s:%d\n", hostname, port);
return NULL;
}
+ if(port) {
+ Curl_addrinfo_set_port(res, port);
+ }
+
dump_addrinfo(conn, res);
return res;
}
#endif /* CURLRES_SYNCH */
-#endif /* CURLRES_IPV6 */
+#endif /* CURLRES_IPV6 */