1 // Test that ASan doesn't raise false alarm when getsockname and getpeername
2 // are called with addrlen=nullptr;
4 // RUN: %clangxx %s -o %t && %run %t 2>&1
8 #include <netinet/in.h>
9 #include <sys/socket.h>
12 const int fd
= socket(AF_INET
, SOCK_DGRAM
, 0);
15 const sockaddr_in sin
= {
16 .sin_family
= AF_INET
,
17 .sin_port
= htons(1234),
20 .s_addr
= htonl(INADDR_LOOPBACK
),
23 assert(connect(fd
, reinterpret_cast<const sockaddr
*>(&sin
), sizeof(sin
)) ==
27 assert(getsockname(fd
, nullptr, nullptr) == -1);
28 assert(errno
== EFAULT
);
31 assert(getpeername(fd
, nullptr, nullptr) == -1);
32 assert(errno
== EFAULT
);