Skip to content

Commit

Permalink
Add validation ai_addrlen in PosixSocketResolveTest (#4022)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
MSoliankoLuxoft committed Sep 9, 2024
1 parent 13e5773 commit 8243f46
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions starboard/nplb/posix_compliance/posix_socket_resolve_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ TEST(PosixSocketResolveTest, SunnyDay) {
++address_count;
if (ai_addr == nullptr && i->ai_addr != nullptr) {
ai_addr = reinterpret_cast<sockaddr_in*>(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;
}
}
Expand Down

0 comments on commit 8243f46

Please sign in to comment.