]> git.proxmox.com Git - rustc.git/blob - src/compiler-rt/test/msan/getaddrinfo.cc
Imported Upstream version 1.6.0+dfsg1
[rustc.git] / src / compiler-rt / test / msan / getaddrinfo.cc
1 // RUN: %clangxx_msan -O0 %s -o %t && %run %t
2
3 #include <sys/types.h>
4 #include <sys/socket.h>
5 #include <netdb.h>
6 #include <stdlib.h>
7
8 void poison_stack_ahead() {
9 char buf[100000];
10 // With -O0 this poisons a large chunk of stack.
11 }
12
13 int main(void) {
14 poison_stack_ahead();
15
16 struct addrinfo *ai;
17
18 // This should trigger loading of libnss_dns and friends.
19 // Those libraries are typically uninstrumented.They will call strlen() on a
20 // stack-allocated buffer, which is very likely to be poisoned. Test that we
21 // don't report this as an UMR.
22 int res = getaddrinfo("not-in-etc-hosts", NULL, NULL, &ai);
23 return 0;
24 }