]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
urlapi: accept :: as a valid IPv6 address
authorDaniel Stenberg <daniel@haxx.se>
Thu, 7 May 2020 10:24:27 +0000 (12:24 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 8 May 2020 06:47:29 +0000 (08:47 +0200)
Text 1560 is extended to verify.

Reported-by: Pavel Volgarev
Fixes #5344
Closes #5351

lib/urlapi.c
tests/libtest/lib1560.c

index 506e244dc4fb4015e59144261f89b8ecc18775ed..37937fbca7ad44f406be1771691988da1d13d57c 100644 (file)
@@ -606,7 +606,7 @@ static CURLUcode hostname_check(struct Curl_URL *u, char *hostname)
     char dest[16]; /* fits a binary IPv6 address */
 #endif
     const char *l = "0123456789abcdefABCDEF:.";
-    if(hlen < 5) /* '[::1]' is the shortest possible valid string */
+    if(hlen < 4) /* '[::]' is the shortest possible valid string */
       return CURLUE_MALFORMED_INPUT;
     hostname++;
     hlen -= 2;
index fbe642c20fb5fb3348b60e211b0d59a196225f7b..ed1a2e4ddb2f2010e2515ec3b943458d84965468 100644 (file)
@@ -129,6 +129,15 @@ struct querycase {
 };
 
 static struct testcase get_parts_list[] ={
+  {"[::1]",
+   "http | [11] | [12] | [13] | [::1] | [15] | / | [16] | [17]",
+   CURLU_GUESS_SCHEME, 0, CURLUE_OK },
+  {"[::]",
+   "http | [11] | [12] | [13] | [::] | [15] | / | [16] | [17]",
+   CURLU_GUESS_SCHEME, 0, CURLUE_OK },
+  {"https://[::1]",
+   "https | [11] | [12] | [13] | [::1] | [15] | / | [16] | [17]",
+   0, 0, CURLUE_OK },
   {"user:moo@ftp.example.com/color/#green?no-black",
    "ftp | user | moo | [13] | ftp.example.com | [15] | /color/ | [16] | "
    "green?no-black",