]> granicus.if.org Git - curl/commitdiff
urlapi: require a non-zero host name length when parsing URL
authorDaniel Stenberg <daniel@haxx.se>
Mon, 13 May 2019 16:42:05 +0000 (18:42 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 14 May 2019 11:39:10 +0000 (13:39 +0200)
Updated test 1560 to verify.

Closes #3880

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

index c66c07f0a8a88f0f738d81b9b55431cbfa33dfaf..0d05f4d92a833c66623250121d6081949e2da1d3 100644 (file)
@@ -636,6 +636,8 @@ static CURLUcode hostname_check(struct Curl_URL *u, char *hostname)
       /* hostname with bad content */
       return CURLUE_MALFORMED_INPUT;
   }
+  if(!hostname[0])
+    return CURLUE_NO_HOST;
   return CURLUE_OK;
 }
 
index 5ad7134d0bdb79851e5d734b7a54012117047868..a18d56a8ef5225a7a68a4de292cc27d496b9cd04 100644 (file)
@@ -140,6 +140,9 @@ static struct testcase get_parts_list[] ={
    "file | [11] | [12] | [13] | [14] | [15] | C:\\programs\\foo | [16] | [17]",
    CURLU_DEFAULT_SCHEME, 0, CURLUE_OK},
 #endif
+  /* URL without host name */
+  {"http://a:b@/x", "",
+   CURLU_DEFAULT_SCHEME, 0, CURLUE_NO_HOST},
   {"boing:80",
    "https | [11] | [12] | [13] | boing | 80 | / | [16] | [17]",
    CURLU_DEFAULT_SCHEME, 0, CURLUE_OK},