From 9f77b36fa100761eb3eabbb87f5111419202a9d5 Mon Sep 17 00:00:00 2001 From: Bhasker Hariharan Date: Thu, 13 Jun 2019 13:40:37 -0700 Subject: Set optlen correctly when calling getsockopt. PiperOrigin-RevId: 253096085 --- test/syscalls/linux/socket_ip_tcp_generic.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/syscalls/linux/socket_ip_tcp_generic.cc b/test/syscalls/linux/socket_ip_tcp_generic.cc index 0b76280a7..a43cf9bce 100644 --- a/test/syscalls/linux/socket_ip_tcp_generic.cc +++ b/test/syscalls/linux/socket_ip_tcp_generic.cc @@ -679,7 +679,7 @@ TEST_P(TCPSocketPairTest, SetCongestionControlFailsForUnsupported) { auto sockets = ASSERT_NO_ERRNO_AND_VALUE(NewSocketPair()); char old_cc[kTcpCaNameMax]; - socklen_t optlen; + socklen_t optlen = sizeof(old_cc); ASSERT_THAT(getsockopt(sockets->first_fd(), IPPROTO_TCP, TCP_CONGESTION, &old_cc, &optlen), SyscallSucceedsWithValue(0)); @@ -690,6 +690,7 @@ TEST_P(TCPSocketPairTest, SetCongestionControlFailsForUnsupported) { SyscallFailsWithErrno(ENOENT)); char got_cc[kTcpCaNameMax]; + optlen = sizeof(got_cc); ASSERT_THAT(getsockopt(sockets->first_fd(), IPPROTO_TCP, TCP_CONGESTION, &got_cc, &optlen), SyscallSucceedsWithValue(0)); -- cgit v1.2.3