Merge pull request #17989 from yashykt/fathomoops

Memset before setting length
pull/16745/head
Yash Tibrewal 6 years ago committed by GitHub
commit c7fa7a9188
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/core/lib/iomgr/buffer_list.cc
  2. 1
      test/core/iomgr/buffer_list_test.cc

@ -188,8 +188,8 @@ void extract_opt_stats_from_cmsg(ConnectionMetrics* metrics,
} }
static int get_socket_tcp_info(grpc_core::tcp_info* info, int fd) { static int get_socket_tcp_info(grpc_core::tcp_info* info, int fd) {
info->length = sizeof(*info) - sizeof(socklen_t);
memset(info, 0, sizeof(*info)); memset(info, 0, sizeof(*info));
info->length = sizeof(*info) - sizeof(socklen_t);
return getsockopt(fd, IPPROTO_TCP, TCP_INFO, info, &(info->length)); return getsockopt(fd, IPPROTO_TCP, TCP_INFO, info, &(info->length));
} }
} /* namespace */ } /* namespace */

@ -66,6 +66,7 @@ static void TestVerifierCalledOnAckVerifier(void* arg,
GPR_ASSERT(ts->acked_time.time.clock_type == GPR_CLOCK_REALTIME); GPR_ASSERT(ts->acked_time.time.clock_type == GPR_CLOCK_REALTIME);
GPR_ASSERT(ts->acked_time.time.tv_sec == 123); GPR_ASSERT(ts->acked_time.time.tv_sec == 123);
GPR_ASSERT(ts->acked_time.time.tv_nsec == 456); GPR_ASSERT(ts->acked_time.time.tv_nsec == 456);
GPR_ASSERT(ts->info.length > 0);
gpr_atm* done = reinterpret_cast<gpr_atm*>(arg); gpr_atm* done = reinterpret_cast<gpr_atm*>(arg);
gpr_atm_rel_store(done, static_cast<gpr_atm>(1)); gpr_atm_rel_store(done, static_cast<gpr_atm>(1));
} }

Loading…
Cancel
Save