]> granicus.if.org Git - curl/commitdiff
CONNECT_TO: fail attempt to set an IPv6 numerical without IPv6 support
authorDaniel Stenberg <daniel@haxx.se>
Mon, 22 Jan 2018 14:28:13 +0000 (15:28 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 23 Jan 2018 07:01:04 +0000 (08:01 +0100)
Bug: https://curl.haxx.se/mail/lib-2018-01/0087.html
Reported-by: John Hascall
Closes #2257

lib/url.c

index d45da5e72004b6e99e870a0ec8028b78ee3766c3..74813e8746f7c5b5f72d9fb51162fb9fff9500d3 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, 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
@@ -3612,6 +3612,7 @@ static CURLcode parse_connect_to_host_port(struct Curl_easy *data,
 
   /* detect and extract RFC6874-style IPv6-addresses */
   if(*hostptr == '[') {
+#ifdef ENABLE_IPV6
     char *ptr = ++hostptr; /* advance beyond the initial bracket */
     while(*ptr && (ISXDIGIT(*ptr) || (*ptr == ':') || (*ptr == '.')))
       ptr++;
@@ -3635,6 +3636,11 @@ static CURLcode parse_connect_to_host_port(struct Curl_easy *data,
      * hostptr first, but I can't see anything wrong with that as no host
      * name nor a numeric can legally start with a bracket.
      */
+#else
+    failf(data, "Use of IPv6 in *_CONNECT_TO without IPv6 support built-in!");
+    free(host_dup);
+    return CURLE_NOT_BUILT_IN;
+#endif
   }
 
   /* Get port number off server.com:1080 */