summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Devin Moore <devinmoore@google.com> 2025-03-18 09:49:13 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2025-03-18 09:49:13 -0700
commit4a95d2d934900b45c8bc210fd15a2331d329c5f7 (patch)
tree327725666a9eb3c404d205cfd806ff3d9392cbdd
parent418b3becdca46c5197720b38a15c9c544c4db92d (diff)
parent99820a88e1d2a512ced47cd09b3658fd905f5943 (diff)
Merge "binderRpcTest: Fix sockaddr_storage handling" into main
-rw-r--r--libs/binder/tests/binderRpcTest.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/libs/binder/tests/binderRpcTest.cpp b/libs/binder/tests/binderRpcTest.cpp
index 170b2adfbb..7c9c452c01 100644
--- a/libs/binder/tests/binderRpcTest.cpp
+++ b/libs/binder/tests/binderRpcTest.cpp
@@ -382,7 +382,7 @@ std::unique_ptr<ProcessSession> BinderRpc::createRpcTestSocketServerProcessEtc(
sockaddr_un addr_un{};
addr_un.sun_family = AF_UNIX;
strcpy(addr_un.sun_path, serverConfig.addr.c_str());
- addr = *reinterpret_cast<sockaddr_storage*>(&addr_un);
+ std::memcpy(&addr, &addr_un, sizeof(sockaddr_un));
addrLen = sizeof(sockaddr_un);
status = session->setupPreconnectedClient({}, [=]() {
@@ -394,7 +394,7 @@ std::unique_ptr<ProcessSession> BinderRpc::createRpcTestSocketServerProcessEtc(
sockaddr_un addr_un{};
addr_un.sun_family = AF_UNIX;
strcpy(addr_un.sun_path, serverConfig.addr.c_str());
- addr = *reinterpret_cast<sockaddr_storage*>(&addr_un);
+ std::memcpy(&addr, &addr_un, sizeof(sockaddr_un));
addrLen = sizeof(sockaddr_un);
status = session->setupUnixDomainClient(serverConfig.addr.c_str());
@@ -409,7 +409,7 @@ std::unique_ptr<ProcessSession> BinderRpc::createRpcTestSocketServerProcessEtc(
.svm_port = static_cast<unsigned int>(serverInfo.port),
.svm_cid = VMADDR_CID_LOCAL,
};
- addr = *reinterpret_cast<sockaddr_storage*>(&addr_vm);
+ std::memcpy(&addr, &addr_vm, sizeof(sockaddr_vm));
addrLen = sizeof(sockaddr_vm);
status = session->setupVsockClient(VMADDR_CID_LOCAL, serverInfo.port);
@@ -420,7 +420,7 @@ std::unique_ptr<ProcessSession> BinderRpc::createRpcTestSocketServerProcessEtc(
addr_in.sin_family = AF_INET;
addr_in.sin_port = htons(serverInfo.port);
inet_aton(ip_addr.c_str(), &addr_in.sin_addr);
- addr = *reinterpret_cast<sockaddr_storage*>(&addr_in);
+ std::memcpy(&addr, &addr_in, sizeof(sockaddr_in));
addrLen = sizeof(sockaddr_in);
status = session->setupInetClient(ip_addr.c_str(), serverInfo.port);