blob: 403d819706a9e5aa52aff6e22f9e604bafea16a0 [file] [log] [blame]
Stephen Hines86277eb2015-03-23 12:06:32 -07001// Check that without suppressions, we catch the issue.
2// RUN: %clangxx_asan -O0 %s -o %t -framework Foundation
3// RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-CRASH %s
4
5// Check that suppressing the interceptor by name works.
6// RUN: echo "interceptor_name:memmove" > %t.supp
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -08007// RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s
Stephen Hines86277eb2015-03-23 12:06:32 -07008
9// Check that suppressing by interceptor name works even without the symbolizer
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -080010// RUN: %env_asan_opts=suppressions='"%t.supp"':symbolize=false %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s
Stephen Hines86277eb2015-03-23 12:06:32 -070011
12// Check that suppressing all reports from a library works.
13// RUN: echo "interceptor_via_lib:CoreFoundation" > %t.supp
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -080014// RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s
Stephen Hines86277eb2015-03-23 12:06:32 -070015
16// Check that suppressing library works even without the symbolizer.
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -080017// RUN: %env_asan_opts=suppressions='"%t.supp"':symbolize=false %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s
Stephen Hines86277eb2015-03-23 12:06:32 -070018
19#include <CoreFoundation/CoreFoundation.h>
20
21int main() {
22 char *a = (char *)malloc(6);
23 strcpy(a, "hello");
24 CFStringRef str =
25 CFStringCreateWithBytes(kCFAllocatorDefault, (unsigned char *)a, 10,
26 kCFStringEncodingUTF8, FALSE); // BOOM
27 fprintf(stderr, "Ignored.\n");
28 free(a);
29}
30
31// CHECK-CRASH: AddressSanitizer: heap-buffer-overflow
32// CHECK-CRASH-NOT: Ignored.
33// CHECK-IGNORE-NOT: AddressSanitizer: heap-buffer-overflow
34// CHECK-IGNORE: Ignored.