1 // Test strict_string_checks option in strstr function
2 // RUN: %clang_asan %s -o %t && %run %t 2>&1
4 // Newer versions of Android's strstr() uses memchr() internally, which actually
5 // does trigger a heap-buffer-overflow (as it tries to find the
6 // null-terminator). The same applies to FreeBSD.
7 // UNSUPPORTED: android, target={{.*freebsd.*}}
8 // RUN: %env_asan_opts=strict_string_checks=false %run %t 2>&1
10 // RUN: %env_asan_opts=strict_string_checks=true not %run %t 2>&1 | FileCheck %s
16 int main(int argc
, char **argv
) {
19 char *s1
= (char*)malloc(size
);
20 char *s2
= (char*)malloc(size
);
21 memset(s1
, fill
, size
);
22 memset(s2
, fill
, size
);
24 char* r
= strstr(s1
, s2
);
25 // CHECK: {{.*ERROR: AddressSanitizer: heap-buffer-overflow on address}}
26 // CHECK: READ of size {{101|100}}