From 8243f46d053eab77914db7a5e2d7071e69dff1ea Mon Sep 17 00:00:00 2001 From: MSoliankoLuxoft Date: Mon, 9 Sep 2024 23:13:18 +0300 Subject: [PATCH] Add validation ai_addrlen in PosixSocketResolveTest (#4022) Enhanced the `SunnyDay` test in `PosixSocketResolveTest` to include checks for the `ai_addrlen` field. The test now verifies that `ai_addrlen` matches the expected size for `sockaddr_in` (IPv4) and sockaddr_in6 (IPv6) based on the `ai_family` value. This ensures that `getaddrinfo` correctly sets the length of the returned socket address structures. b/349469318 Signed-off-by: Mykola Solianko --- starboard/nplb/posix_compliance/posix_socket_resolve_test.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/starboard/nplb/posix_compliance/posix_socket_resolve_test.cc b/starboard/nplb/posix_compliance/posix_socket_resolve_test.cc index e2d2026150df..3aaed7f969b1 100644 --- a/starboard/nplb/posix_compliance/posix_socket_resolve_test.cc +++ b/starboard/nplb/posix_compliance/posix_socket_resolve_test.cc @@ -41,6 +41,11 @@ TEST(PosixSocketResolveTest, SunnyDay) { ++address_count; if (ai_addr == nullptr && i->ai_addr != nullptr) { ai_addr = reinterpret_cast(i->ai_addr); + if (i->ai_family == AF_INET) { + EXPECT_EQ(i->ai_addrlen, sizeof(struct sockaddr_in)); + } else if (i->ai_family == AF_INET6) { + EXPECT_EQ(i->ai_addrlen, sizeof(struct sockaddr_in6)); + } break; } }