1 | // RUN: %clangxx_asan -O0 -g %s -o %t && %env_asan_opts=handle_ioctl=1 not %run %t 2>&1 | FileCheck %s |
2 | // RUN: %clangxx_asan -O3 -g %s -o %t && %env_asan_opts=handle_ioctl=1 not %run %t 2>&1 | FileCheck %s |
3 | |
4 | // RUN: %clangxx_asan -O0 -g %s -o %t && %run %t |
5 | // RUN: %clangxx_asan -O3 -g %s -o %t && %run %t |
6 | |
7 | #include <assert.h> |
8 | #include <stdlib.h> |
9 | #include <sys/ioctl.h> |
10 | #include <sys/socket.h> |
11 | #include <unistd.h> |
12 | |
13 | #if defined(__sun__) && defined(__svr4__) |
14 | #include <sys/filio.h> |
15 | #endif |
16 | |
17 | int main(int argc, char **argv) { |
18 | int fd = socket(AF_UNIX, SOCK_DGRAM, protocol: 0); |
19 | |
20 | int nonblock; |
21 | int res = ioctl(fd: fd, FIONBIO, &nonblock + 1); |
22 | // CHECK: AddressSanitizer: stack-buffer-overflow |
23 | // CHECK: READ of size 4 at |
24 | // CHECK: {{#.* in main .*ioctl.cpp:}}[[@LINE-3]] |
25 | assert(res == 0); |
26 | close(fd: fd); |
27 | return 0; |
28 | } |
29 | |