diff options
author | 2018-09-09 18:27:27 -0700 | |
---|---|---|
committer | 2018-09-09 18:27:27 -0700 | |
commit | 58f6912df8d85844d957e0e2b937cc58d8cce276 (patch) | |
tree | 2c80f168ab73f131eb6f928d4f2432020566c934 /src/core/ext/filters/client_channel | |
parent | 23a24f59613019d47f88f799ba2b9d84d825a712 (diff) | |
parent | 8cf33aa8fabfd9eeeb9e89f0796121d94cde7e34 (diff) |
Merge pull request #16517 from sreecha/fix-addrlen
Fix ipv6 address parsing issue
Diffstat (limited to 'src/core/ext/filters/client_channel')
-rw-r--r-- | src/core/ext/filters/client_channel/parse_address.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/core/ext/filters/client_channel/parse_address.cc b/src/core/ext/filters/client_channel/parse_address.cc index b3900114ad..7e726dd562 100644 --- a/src/core/ext/filters/client_channel/parse_address.cc +++ b/src/core/ext/filters/client_channel/parse_address.cc @@ -125,9 +125,16 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr, char* host_end = static_cast<char*>(gpr_memrchr(host, '%', strlen(host))); if (host_end != nullptr) { GPR_ASSERT(host_end >= host); - char host_without_scope[GRPC_INET6_ADDRSTRLEN]; + char host_without_scope[GRPC_INET6_ADDRSTRLEN + 1]; size_t host_without_scope_len = static_cast<size_t>(host_end - host); uint32_t sin6_scope_id = 0; + if (host_without_scope_len > GRPC_INET6_ADDRSTRLEN) { + gpr_log(GPR_ERROR, + "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; + } strncpy(host_without_scope, host, host_without_scope_len); host_without_scope[host_without_scope_len] = '\0'; if (grpc_inet_pton(GRPC_AF_INET6, host_without_scope, &in6->sin6_addr) == |