]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
urlapi: accept port number zero
authorDaniel Stenberg <daniel@haxx.se>
Fri, 3 Dec 2021 14:56:58 +0000 (15:56 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 3 Dec 2021 21:58:41 +0000 (22:58 +0100)
This is a regression since 7.62.0 (fb30ac5a2d).

Updated test 1560 accordingly

Reported-by: Brad Fitzpatrick
Fixes #8090
Closes #8091

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

index 372ffe50a72c80d1beb1bd91bd3c3780970f005b..d88db2978480ebe339072fa9596d73a0c57e9a7d 100644 (file)
@@ -605,9 +605,7 @@ UNITTEST CURLUcode Curl_parse_port(struct Curl_URL *u, char *hostname,
 
     port = strtol(portptr + 1, &rest, 10);  /* Port number must be decimal */
 
-    if((port <= 0) || (port > 0xffff))
-      /* Single unix standard says port numbers are 16 bits long, but we don't
-         treat port zero as OK. */
+    if(port > 0xffff)
       return CURLUE_BAD_PORT_NUMBER;
 
     if(rest[0])
index f09454c451daac0ee3cc49d49638abba718b2714..7a4e12b78950959642d9f2be9013c9bfbfb9bbd2 100644 (file)
@@ -308,9 +308,13 @@ static const struct testcase get_parts_list[] ={
   {"https://example.com:65536",
    "",
    CURLU_DEFAULT_SCHEME, 0, CURLUE_BAD_PORT_NUMBER},
-  {"https://example.com:0#moo",
+  {"https://example.com:-1#moo",
    "",
    CURLU_DEFAULT_SCHEME, 0, CURLUE_BAD_PORT_NUMBER},
+  {"https://example.com:0#moo",
+   "https | [11] | [12] | [13] | example.com | 0 | / | "
+   "[16] | moo",
+   CURLU_DEFAULT_SCHEME, 0, CURLUE_OK},
   {"https://example.com:01#moo",
    "https | [11] | [12] | [13] | example.com | 1 | / | "
    "[16] | moo",