blob: 47d80f80db2bc298091c8bdfb3b4dbdef33e4f93 [file] [log] [blame]
Pirama Arumuga Nainar7c915052015-04-08 08:58:29 -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 a function name works within a no-fork sandbox
6// RUN: echo "interceptor_via_fun:CFStringCreateWithBytes" > %t.supp
Pirama Arumuga Nainarcdce50b2015-07-01 12:26:56 -07007// RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:suppressions=%t.supp \
Pirama Arumuga Nainar7c915052015-04-08 08:58:29 -07008// 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
13int 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.