1 // RUN: %clangxx_msan -O0 %s -o %t && %run %t %p 2>&1
2 // RUN: %clangxx_msan -O0 -D_FILE_OFFSET_BITS=64 %s -o %t && %run %t %p 2>&1
3 // RUN: %clangxx_msan -O3 %s -o %t && %run %t %p 2>&1
13 #if defined(__FreeBSD__) || defined(__NetBSD__)
14 #include <sys/socket.h> // To define 'struct sockaddr'.
17 #include <sanitizer/msan_interface.h>
19 #define CHECK_AND_PUSH(addr, size) \
21 assert(-1 == __msan_test_shadow(addr, sizeof(size))); \
22 ranges.push_back(std::make_pair((void *)addr, (size_t)size)); \
25 int main(int argc
, char *argv
[]) {
28 assert(0 == __msan_test_shadow(&ifas
, sizeof(ifaddrs
*)));
29 int res
= getifaddrs(&ifas
);
31 assert(errno
== ENOSYS
);
32 printf("getifaddrs() is not implemented\n");
36 assert(-1 == __msan_test_shadow(&ifas
, sizeof(ifaddrs
*)));
38 std::vector
<std::pair
<void *, size_t> > ranges
;
41 CHECK_AND_PUSH(p
, sizeof(ifaddrs
));
42 CHECK_AND_PUSH(p
->ifa_name
, strlen(p
->ifa_name
) + 1);
43 CHECK_AND_PUSH(p
->ifa_addr
, sizeof(*p
->ifa_addr
));
44 CHECK_AND_PUSH(p
->ifa_netmask
, sizeof(*p
->ifa_netmask
));
45 CHECK_AND_PUSH(p
->ifa_broadaddr
, sizeof(*p
->ifa_broadaddr
));
46 CHECK_AND_PUSH(p
->ifa_dstaddr
, sizeof(*p
->ifa_dstaddr
));
51 for (int i
= 0; i
< ranges
.size(); i
++)
52 assert(0 == __msan_test_shadow(ranges
[i
].first
, ranges
[i
].second
));