Follow the no_logging param to parse_ipv6_host_port

pull/16628/head
Alexander Polcyn 6 years ago
parent 07eecd8421
commit 2062504cd7
  1. 21
      src/core/ext/filters/client_channel/parse_address.cc

@ -129,30 +129,37 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr,
size_t host_without_scope_len = static_cast<size_t>(host_end - host); size_t host_without_scope_len = static_cast<size_t>(host_end - host);
uint32_t sin6_scope_id = 0; uint32_t sin6_scope_id = 0;
if (host_without_scope_len > GRPC_INET6_ADDRSTRLEN) { if (host_without_scope_len > GRPC_INET6_ADDRSTRLEN) {
gpr_log(GPR_ERROR, if (log_errors) {
"invalid ipv6 address length %zu. Length cannot be greater than " gpr_log(
"GRPC_INET6_ADDRSTRLEN i.e %d)", GPR_ERROR,
host_without_scope_len, GRPC_INET6_ADDRSTRLEN); "invalid ipv6 address length %zu. Length cannot be greater than "
"GRPC_INET6_ADDRSTRLEN i.e %d)",
host_without_scope_len, GRPC_INET6_ADDRSTRLEN);
}
goto done; goto done;
} }
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 (grpc_inet_pton(GRPC_AF_INET6, host_without_scope, &in6->sin6_addr) == if (grpc_inet_pton(GRPC_AF_INET6, host_without_scope, &in6->sin6_addr) ==
0) { 0) {
gpr_log(GPR_ERROR, "invalid ipv6 address: '%s'", host_without_scope); if (log_errors) {
gpr_log(GPR_ERROR, "invalid ipv6 address: '%s'", host_without_scope);
}
goto done; goto done;
} }
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,
&sin6_scope_id) == 0) { &sin6_scope_id) == 0) {
gpr_log(GPR_ERROR, "invalid ipv6 scope id: '%s'", host_end + 1); if (log_errors) {
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. // Handle "sin6_scope_id" being type "u_long". See grpc issue #10027.
in6->sin6_scope_id = sin6_scope_id; in6->sin6_scope_id = sin6_scope_id;
} else { } else {
if (grpc_inet_pton(GRPC_AF_INET6, host, &in6->sin6_addr) == 0) { if (grpc_inet_pton(GRPC_AF_INET6, host, &in6->sin6_addr) == 0) {
gpr_log(GPR_ERROR, "invalid ipv6 address: '%s'", host); if (log_errors) gpr_log(GPR_ERROR, "invalid ipv6 address: '%s'", host);
goto done; goto done;
} }
} }

Loading…
Cancel
Save