Skip to content
Snippets Groups Projects
Commit 97129b06 authored by apolcyn's avatar apolcyn Committed by GitHub
Browse files

Merge pull request #10076 from apolcyn/fix_in6_scope_id_windows_issue

fix in6_scope_id incompatibiliity issue on windows/mingw
parents f13011b6 648229ec
No related branches found
No related tags found
No related merge requests found
...@@ -128,6 +128,7 @@ int parse_ipv6(grpc_uri *uri, grpc_resolved_address *resolved_addr) { ...@@ -128,6 +128,7 @@ int parse_ipv6(grpc_uri *uri, grpc_resolved_address *resolved_addr) {
GPR_ASSERT(host_end >= host); GPR_ASSERT(host_end >= host);
char host_without_scope[INET6_ADDRSTRLEN]; char host_without_scope[INET6_ADDRSTRLEN];
size_t host_without_scope_len = (size_t)(host_end - host); size_t host_without_scope_len = (size_t)(host_end - host);
uint32_t sin6_scope_id = 0;
strncpy(host_without_scope, host, host_without_scope_len); strncpy(host_without_scope, host, host_without_scope_len);
host_without_scope[host_without_scope_len] = '\0'; host_without_scope[host_without_scope_len] = '\0';
if (inet_pton(AF_INET6, host_without_scope, &in6->sin6_addr) == 0) { if (inet_pton(AF_INET6, host_without_scope, &in6->sin6_addr) == 0) {
...@@ -136,10 +137,12 @@ int parse_ipv6(grpc_uri *uri, grpc_resolved_address *resolved_addr) { ...@@ -136,10 +137,12 @@ int parse_ipv6(grpc_uri *uri, grpc_resolved_address *resolved_addr) {
} }
if (gpr_parse_bytes_to_uint32(host_end + 1, if (gpr_parse_bytes_to_uint32(host_end + 1,
strlen(host) - host_without_scope_len - 1, strlen(host) - host_without_scope_len - 1,
&in6->sin6_scope_id) == 0) { &sin6_scope_id) == 0) {
gpr_log(GPR_ERROR, "invalid ipv6 scope id: '%s'", host_end + 1); gpr_log(GPR_ERROR, "invalid ipv6 scope id: '%s'", host_end + 1);
goto done; goto done;
} }
// Handle "sin6_scope_id" being type "u_long". See grpc issue ##10027.
in6->sin6_scope_id = sin6_scope_id;
} else { } else {
if (inet_pton(AF_INET6, host, &in6->sin6_addr) == 0) { if (inet_pton(AF_INET6, host, &in6->sin6_addr) == 0) {
gpr_log(GPR_ERROR, "invalid ipv6 address: '%s'", host); gpr_log(GPR_ERROR, "invalid ipv6 address: '%s'", host);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment