Merge pull request #19846 from AspirinSJL/msan_fix

Fix uninitialized memory in sockaddr utils
pull/19852/head
Juanli Shen 5 years ago committed by GitHub
commit 5eef4ca270
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/core/lib/iomgr/sockaddr_utils.cc

@ -201,13 +201,11 @@ int grpc_sockaddr_to_string(char** out,
} }
void grpc_string_to_sockaddr(grpc_resolved_address* out, char* addr, int port) { void grpc_string_to_sockaddr(grpc_resolved_address* out, char* addr, int port) {
memset(out, 0, sizeof(grpc_resolved_address));
grpc_sockaddr_in6* addr6 = (grpc_sockaddr_in6*)out->addr; grpc_sockaddr_in6* addr6 = (grpc_sockaddr_in6*)out->addr;
grpc_sockaddr_in* addr4 = (grpc_sockaddr_in*)out->addr; grpc_sockaddr_in* addr4 = (grpc_sockaddr_in*)out->addr;
if (grpc_inet_pton(GRPC_AF_INET6, addr, &addr6->sin6_addr) == 1) { if (grpc_inet_pton(GRPC_AF_INET6, addr, &addr6->sin6_addr) == 1) {
addr6->sin6_family = GRPC_AF_INET6; addr6->sin6_family = GRPC_AF_INET6;
addr6->sin6_flowinfo = 0;
addr6->sin6_scope_id = 0;
out->len = sizeof(grpc_sockaddr_in6); out->len = sizeof(grpc_sockaddr_in6);
} else if (grpc_inet_pton(GRPC_AF_INET, addr, &addr4->sin_addr) == 1) { } else if (grpc_inet_pton(GRPC_AF_INET, addr, &addr4->sin_addr) == 1) {
addr4->sin_family = GRPC_AF_INET; addr4->sin_family = GRPC_AF_INET;

Loading…
Cancel
Save