Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 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 |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 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 | int main(int argc, char **argv) { |
| 14 | int fd = socket(AF_INET, SOCK_DGRAM, 0); |
| 15 | |
| 16 | int nonblock; |
| 17 | int res = ioctl(fd, FIONBIO, &nonblock + 1); |
| 18 | // CHECK: AddressSanitizer: stack-buffer-overflow |
| 19 | // CHECK: READ of size 4 at |
| 20 | // CHECK: {{#.* in main .*ioctl.cc:}}[[@LINE-3]] |
| 21 | assert(res == 0); |
| 22 | close(fd); |
| 23 | return 0; |
| 24 | } |