Alexey Samsonov | c65fe5e | 2013-06-10 07:55:12 +0000 | [diff] [blame] | 1 | // RUN: %clangxx_asan -O0 -g %s -o %t && ASAN_OPTIONS=handle_ioctl=1 %t 2>&1 | %symbolize | FileCheck %s |
| 2 | // RUN: %clangxx_asan -O3 -g %s -o %t && ASAN_OPTIONS=handle_ioctl=1 %t 2>&1 | %symbolize | FileCheck %s |
Evgeniy Stepanov | 745dd0d | 2013-06-07 13:00:47 +0000 | [diff] [blame] | 3 | |
Alexey Samsonov | c65fe5e | 2013-06-10 07:55:12 +0000 | [diff] [blame] | 4 | // RUN: %clangxx_asan -O0 -g %s -o %t && %t |
| 5 | // RUN: %clangxx_asan -O3 -g %s -o %t && %t |
Evgeniy Stepanov | 745dd0d | 2013-06-07 13:00:47 +0000 | [diff] [blame] | 6 | |
Alexey Samsonov | fdde5a9 | 2013-06-10 14:17:08 +0000 | [diff] [blame^] | 7 | // See https://code.google.com/p/address-sanitizer/issues/detail?id=195 |
| 8 | // XFAIL: darwin |
| 9 | |
Evgeniy Stepanov | 745dd0d | 2013-06-07 13:00:47 +0000 | [diff] [blame] | 10 | #include <assert.h> |
| 11 | #include <stdlib.h> |
| 12 | #include <sys/ioctl.h> |
| 13 | #include <sys/socket.h> |
| 14 | #include <unistd.h> |
| 15 | |
| 16 | int main(int argc, char **argv) { |
| 17 | int fd = socket(AF_INET, SOCK_DGRAM, 0); |
| 18 | |
| 19 | int nonblock; |
| 20 | int res = ioctl(fd, FIONBIO, &nonblock + 1); |
| 21 | // CHECK: AddressSanitizer: stack-buffer-overflow |
| 22 | // CHECK: READ of size 4 at |
| 23 | // CHECK: #{{.*}} in main {{.*}}/ioctl.cc:[[@LINE-3]] |
| 24 | assert(res == 0); |
| 25 | close(fd); |
| 26 | return 0; |
| 27 | } |