1 // Test that ASan doesn't raise false alarm when MSG_TRUNC is present.
3 // RUN: %clangxx %s -o %t && %run %t 2>&1
5 // UNSUPPORTED: android
10 #include <sys/socket.h>
11 #include <netinet/ip.h>
15 int fd_0
= socket(AF_INET
, SOCK_DGRAM
, 0);
16 int fd_1
= socket(AF_INET
, SOCK_DGRAM
, 0);
17 struct sockaddr_in sin
;
18 socklen_t len
= sizeof(sin
);
19 char *buf
= (char *)malloc(1);
21 sin
.sin_family
= AF_INET
;
22 // Choose a random port to bind.
24 sin
.sin_addr
.s_addr
= INADDR_ANY
;
26 assert(bind(fd_1
, (struct sockaddr
*)&sin
, sizeof(sin
)) == 0);
27 // Get the address and port binded.
28 assert(getsockname(fd_1
, (struct sockaddr
*)&sin
, &len
) == 0);
29 assert(sendto(fd_0
, "hello", strlen("hello"), MSG_DONTWAIT
,
30 (struct sockaddr
*)&sin
, sizeof(sin
)) != -1);
31 assert(recv(fd_1
, buf
, 1, MSG_TRUNC
) != -1);