Skip to content

Commit 1772de7

Browse files
mgornytstellar
authored andcommitted
[compiler-rt] Fix endianness in get_sock_peer_name test
Fix passing the port and IP address with the wrong endianness in get_sock_peer_name() that causes the connect() to fail inside without an outgoing network interface (it's trying to connect to 1.0.0.127 instead of 127.0.0.1). Differential Revision: https://reviews.llvm.org/D119461 (cherry picked from commit c65fb0c)
1 parent 71e4987 commit 1772de7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

compiler-rt/test/sanitizer_common/TestCases/Linux/get_sock_peer_name.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ int main() {
1717

1818
const sockaddr_in sin = {
1919
.sin_family = AF_INET,
20-
.sin_port = 1234,
20+
.sin_port = htons(1234),
2121
.sin_addr =
2222
{
23-
.s_addr = INADDR_LOOPBACK,
23+
.s_addr = htonl(INADDR_LOOPBACK),
2424
},
2525
};
2626
assert(connect(fd, reinterpret_cast<const sockaddr *>(&sin), sizeof(sin)) ==

0 commit comments

Comments
 (0)