[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / Linux / get_sock_peer_name.cpp
blobd0bcca8da6582b151191d69fdf3248277121e4f3
1 // Test that ASan doesn't raise false alarm when getsockname and getpeername
2 // are called with addrlen=nullptr;
3 //
4 // RUN: %clangxx %s -o %t && %run %t 2>&1
6 #include <assert.h>
7 #include <errno.h>
8 #include <netinet/in.h>
9 #include <sys/socket.h>
11 int main() {
12 const int fd = socket(AF_INET, SOCK_DGRAM, 0);
13 assert(fd >= 0);
15 const sockaddr_in sin = {
16 .sin_family = AF_INET,
17 .sin_port = htons(1234),
18 .sin_addr =
20 .s_addr = htonl(INADDR_LOOPBACK),
23 assert(connect(fd, reinterpret_cast<const sockaddr *>(&sin), sizeof(sin)) ==
24 0);
26 errno = 0;
27 assert(getsockname(fd, nullptr, nullptr) == -1);
28 assert(errno == EFAULT);
30 errno = 0;
31 assert(getpeername(fd, nullptr, nullptr) == -1);
32 assert(errno == EFAULT);
34 return 0;