From 10174f8a47fd998bdf0219badb1ee7a89aab6718 Mon Sep 17 00:00:00 2001 From: hai007 Date: Fri, 28 Apr 2023 17:15:50 -0700 Subject: [PATCH] Fix data overflow problem PiperOrigin-RevId: 528023236 --- connections/implementation/p2p_cluster_pcp_handler_test.cc | 3 ++- .../implementation/p2p_point_to_point_pcp_handler_test.cc | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/connections/implementation/p2p_cluster_pcp_handler_test.cc b/connections/implementation/p2p_cluster_pcp_handler_test.cc index 1b93c9cb..3de5438f 100644 --- a/connections/implementation/p2p_cluster_pcp_handler_test.cc +++ b/connections/implementation/p2p_cluster_pcp_handler_test.cc @@ -268,11 +268,12 @@ TEST_P(P2pClusterPcpHandlerTest, CanConnect) { const std::string kBssid = "34:36:3B:C7:8C:71"; const std::int32_t kFreq = 5200; - constexpr char kIp4Bytes[] = {(char)192, (char)168, (char)1, (char)37}; + constexpr char kIp4Bytes[] = {(char)192, (char)168, (char)1, (char)37, 0}; connection_options_.connection_info.supports_5_ghz = true; connection_options_.connection_info.bssid = kBssid; connection_options_.connection_info.ap_frequency = kFreq; + connection_options_.connection_info.ip_address.resize(4); connection_options_.connection_info.ip_address = std::string(kIp4Bytes); client_b_.AddCancellationFlag(discovered.endpoint_id); diff --git a/connections/implementation/p2p_point_to_point_pcp_handler_test.cc b/connections/implementation/p2p_point_to_point_pcp_handler_test.cc index 5eab2d1c..65d16f09 100644 --- a/connections/implementation/p2p_point_to_point_pcp_handler_test.cc +++ b/connections/implementation/p2p_point_to_point_pcp_handler_test.cc @@ -207,11 +207,12 @@ TEST_P(P2pPointToPointPcpHandlerTest, CanConnect) { const std::string kBssid = "34:36:3B:C7:8C:71"; const std::int32_t kFreq = 5200; - constexpr char kIp4Bytes[] = {(char)192, (char)168, (char)1, (char)37}; + constexpr char kIp4Bytes[] = {(char)192, (char)168, (char)1, (char)37, 0}; connection_options_.connection_info.supports_5_ghz = true; connection_options_.connection_info.bssid = kBssid; connection_options_.connection_info.ap_frequency = kFreq; + connection_options_.connection_info.ip_address.resize(4); connection_options_.connection_info.ip_address = std::string(kIp4Bytes); client_b_.AddCancellationFlag(discovered.endpoint_id);