]> granicus.if.org Git - curl/commitdiff
URL: fix IPv6 numeral address parser
authorDaniel Stenberg <daniel@haxx.se>
Fri, 2 Nov 2018 14:11:16 +0000 (15:11 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 2 Nov 2018 23:14:04 +0000 (00:14 +0100)
Regression from 46e164069d1a52. Extended test 1560 to verify.

Reported-by: tpaukrt on github
Fixes #3218
Closes #3219

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

index c53e523434c95bc86a04b9a74f02389aa9a2fa9d..18a6076fff45635f6fbf780a5e07f8eb07a4def7 100644 (file)
@@ -499,8 +499,12 @@ static CURLUcode parse_port(struct Curl_URL *u, char *hostname)
      (']' == endbracket)) {
     /* this is a RFC2732-style specified IP-address */
     portptr = &hostname[len];
-    if (*portptr != ':')
-      return CURLUE_MALFORMED_INPUT;
+    if(*portptr) {
+      if(*portptr != ':')
+        return CURLUE_MALFORMED_INPUT;
+    }
+    else
+      portptr = NULL;
   }
   else
     portptr = strchr(hostname, ':');
index e0faa12b29286b8213588bb62ca6e7ad963efd57..57469a9063d6a531f88363e3f2ee475937cf91b4 100644 (file)
@@ -128,6 +128,15 @@ struct querycase {
 };
 
 static struct testcase get_parts_list[] ={
+  {"http://[fd00:a41::50]:8080",
+   "http | [11] | [12] | [13] | [fd00:a41::50] | 8080 | / | [16] | [17]",
+   CURLU_DEFAULT_SCHEME, 0, CURLUE_OK},
+  {"http://[fd00:a41::50]/",
+   "http | [11] | [12] | [13] | [fd00:a41::50] | [15] | / | [16] | [17]",
+   CURLU_DEFAULT_SCHEME, 0, CURLUE_OK},
+  {"http://[fd00:a41::50]",
+   "http | [11] | [12] | [13] | [fd00:a41::50] | [15] | / | [16] | [17]",
+   CURLU_DEFAULT_SCHEME, 0, CURLUE_OK},
   {"https://[::1%252]:1234",
    "https | [11] | [12] | [13] | [::1%252] | 1234 | / | [16] | [17]",
    CURLU_DEFAULT_SCHEME, 0, CURLUE_OK},