diff options
author | Daniel Stenberg <daniel@haxx.se> | 2021-12-03 15:56:58 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2021-12-03 16:10:49 +0100 |
commit | f9b226ba707a63b63e83435527dd4b5c2bba4c0d (patch) | |
tree | 82d661c09e25c39892e6d659b999db655ecfae59 | |
parent | c8a3046555378f81b22d51e3887df8a5cf1ab5bf (diff) | |
download | curl-bagder/accept-port-zero.tar.gz |
urlapi: accept port number zerobagder/accept-port-zero
This is a regression since 7.62.0 (fb30ac5a2d).
Updated test 1560 accordingly
Reported-by: Brad Fitzpatrick
Fixes #8090
-rw-r--r-- | lib/urlapi.c | 4 | ||||
-rw-r--r-- | tests/libtest/lib1560.c | 6 |
2 files changed, 6 insertions, 4 deletions
diff --git a/lib/urlapi.c b/lib/urlapi.c index 372ffe50a..d88db2978 100644 --- a/lib/urlapi.c +++ b/lib/urlapi.c @@ -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]) diff --git a/tests/libtest/lib1560.c b/tests/libtest/lib1560.c index f09454c45..7a4e12b78 100644 --- a/tests/libtest/lib1560.c +++ b/tests/libtest/lib1560.c @@ -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", |