diff options
author | Daniel Gustafsson <daniel@yesql.se> | 2018-12-30 20:11:57 +0100 |
---|---|---|
committer | Daniel Gustafsson <daniel@yesql.se> | 2018-12-30 20:11:57 +0100 |
commit | a4482b21bd8bb0ac7cfb3471bad32bf84f829805 (patch) | |
tree | cd1eff185c2ca2f2d56b4dca942de741a2b97862 /lib/urlapi.c | |
parent | 2a8801d7ba5ec91fb2db83d8627587a5e0c0f5a5 (diff) | |
download | curl-a4482b21bd8bb0ac7cfb3471bad32bf84f829805.tar.gz |
urlapi: fix parsing ipv6 with zone index
The previous fix for parsing IPv6 URLs with a zone index was a paddle
short for URLs without an explicit port. This patch fixes that case
and adds a unit test case.
This bug was highlighted by issue #3408, and while it's not the full
fix for the problem there it is an isolated bug that should be fixed
regardless.
Closes #3411
Reported-by: GitYuanQu on github
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
Diffstat (limited to 'lib/urlapi.c')
-rw-r--r-- | lib/urlapi.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/urlapi.c b/lib/urlapi.c index 6919ff1bd..3af8e9399 100644 --- a/lib/urlapi.c +++ b/lib/urlapi.c @@ -510,8 +510,11 @@ UNITTEST CURLUcode Curl_parse_port(struct Curl_URL *u, char *hostname) portptr = &hostname[len]; else if('%' == endbracket) { int zonelen = len; - if(1 == sscanf(hostname + zonelen, "25%*[^]]]%c%n", &endbracket, &len)) - portptr = &hostname[--zonelen + len]; + if(1 == sscanf(hostname + zonelen, "25%*[^]]%c%n", &endbracket, &len)) { + if(']' != endbracket) + return CURLUE_MALFORMED_INPUT; + portptr = &hostname[--zonelen + len + 1]; + } else return CURLUE_MALFORMED_INPUT; } |