1 // RUN: %clang_cl_asan -O0 %s -Fe%t
2 // RUN: not %run %t 2>&1 | FileCheck %s
3 
4 #include <stdio.h>
5 #include <string.h>
6 
main()7 int main() {
8   char str[] = "Hello";
9   if (5 != strlen(str))
10     return 1;
11 
12   printf("Initial test OK\n");
13   fflush(0);
14 // CHECK: Initial test OK
15 
16   str[5] = '!';  // Losing '\0' at the end.
17   int len = strlen(str);
18 // CHECK: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
19 // FIXME: Should be READ of size 1, see issue 155.
20 // CHECK: READ of size {{[0-9]+}} at [[ADDR]] thread T0
21 // CHECK:      strlen
22 // CHECK-NEXT: main {{.*}}intercept_strlen.cc:[[@LINE-5]]
23 // CHECK: Address [[ADDR]] is located in stack of thread T0 at offset {{.*}} in frame
24 // CHECK-NEXT: main {{.*}}intercept_strlen.cc
25 // CHECK: 'str'{{.*}} <== Memory access at offset {{.*}} overflows this variable
26   return len < 6;
27 }
28