[compiler-rt] c65fb0c - [compiler-rt] Fix endianness in get_sock_peer_name test
Michał Górny via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 10 11:16:17 PST 2022
Author: Michał Górny
Date: 2022-02-10T20:15:56+01:00
New Revision: c65fb0cdf26296ae83d23260337d1231d0249020
URL: https://github.com/llvm/llvm-project/commit/c65fb0cdf26296ae83d23260337d1231d0249020
DIFF: https://github.com/llvm/llvm-project/commit/c65fb0cdf26296ae83d23260337d1231d0249020.diff
LOG: [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
Added:
Modified:
compiler-rt/test/sanitizer_common/TestCases/Linux/get_sock_peer_name.cpp
Removed:
################################################################################
diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/get_sock_peer_name.cpp b/compiler-rt/test/sanitizer_common/TestCases/Linux/get_sock_peer_name.cpp
index d4e6189d61703..04ac7a1072459 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Linux/get_sock_peer_name.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/get_sock_peer_name.cpp
@@ -17,10 +17,10 @@ int main() {
const sockaddr_in sin = {
.sin_family = AF_INET,
- .sin_port = 1234,
+ .sin_port = htons(1234),
.sin_addr =
{
- .s_addr = INADDR_LOOPBACK,
+ .s_addr = htonl(INADDR_LOOPBACK),
},
};
assert(connect(fd, reinterpret_cast<const sockaddr *>(&sin), sizeof(sin)) ==
More information about the llvm-commits
mailing list