Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

urlapi: fix parsing ipv6 with zone index #3411

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/urlapi.c
Expand Up @@ -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;
}
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/unit1653.c
Expand Up @@ -83,6 +83,14 @@ UNITTEST_START
free(ipv6port);
curl_url_cleanup(u);

/* Valid IPv6 with zone index without port number */
u = curl_url();
ipv6port = strdup("[fe80::250:56ff:fea7:da15%25eth3]");
ret = Curl_parse_port(u, ipv6port);
fail_unless(ret == CURLUE_OK, "Curl_parse_port returned error");
free(ipv6port);
curl_url_cleanup(u);

/* Valid IPv6 with port number */
u = curl_url();
ipv6port = strdup("[fe80::250:56ff:fea7:da15]:81");
Expand Down