Home | History | Annotate | Download | only in Posix
      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 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 }
     25