blob: bf2772d988fa7b051a10ceb1896b461724b57f91 [file] [log] [blame]
Alexey Samsonovc65fe5e2013-06-10 07:55:12 +00001// 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 Stepanov745dd0d2013-06-07 13:00:47 +00003
Alexey Samsonovc65fe5e2013-06-10 07:55:12 +00004// RUN: %clangxx_asan -O0 -g %s -o %t && %t
5// RUN: %clangxx_asan -O3 -g %s -o %t && %t
Evgeniy Stepanov745dd0d2013-06-07 13:00:47 +00006
Alexey Samsonovfdde5a92013-06-10 14:17:08 +00007// See https://code.google.com/p/address-sanitizer/issues/detail?id=195
8// XFAIL: darwin
9
Evgeniy Stepanov745dd0d2013-06-07 13:00:47 +000010#include <assert.h>
11#include <stdlib.h>
12#include <sys/ioctl.h>
13#include <sys/socket.h>
14#include <unistd.h>
15
16int 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}