1 // 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 a function name works within a no-fork sandbox
6 // RUN: echo "interceptor_via_fun:CFStringCreateWithBytes" > %t.supp
7 // RUN: %env_asan_opts=suppressions='"%t.supp"' \
8 // RUN:   sandbox-exec -p '(version 1)(allow default)(deny process-fork)' \
9 // RUN:   %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s
10 
11 #include <CoreFoundation/CoreFoundation.h>
12 
main()13 int main() {
14   char *a = (char *)malloc(6);
15   strcpy(a, "hello");
16   CFStringRef str =
17       CFStringCreateWithBytes(kCFAllocatorDefault, (unsigned char *)a, 10,
18                               kCFStringEncodingUTF8, FALSE);  // BOOM
19   fprintf(stderr, "Ignored.\n");
20   free(a);
21 }
22 
23 // CHECK-CRASH: AddressSanitizer: heap-buffer-overflow
24 // CHECK-CRASH-NOT: Ignored.
25 // CHECK-IGNORE-NOT: AddressSanitizer: heap-buffer-overflow
26 // CHECK-IGNORE: Ignored.
27