37 lines · cpp
1// Check that without suppressions, we catch the issue.2// RUN: %clangxx_asan -O0 %s -o %t -framework Foundation3// RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-CRASH %s4 5// Check that suppressing the interceptor by name works.6// RUN: echo "interceptor_name:memmove" > %t.supp7// RUN: echo "interceptor_name:memcpy" >> %t.supp8// RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s9 10// Check that suppressing by interceptor name works even without the symbolizer11// RUN: %env_asan_opts=suppressions='"%t.supp"':symbolize=false %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s12 13// Check that suppressing all reports from a library works.14// RUN: echo "interceptor_via_lib:CoreFoundation" > %t.supp15// RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s16 17// Check that suppressing library works even without the symbolizer.18// RUN: %env_asan_opts=suppressions='"%t.supp"':symbolize=false %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s19 20#include <CoreFoundation/CoreFoundation.h>21 22int main() {23 char *a = (char *)malloc(6);24 strcpy(a, "hello");25 CFStringRef str =26 CFStringCreateWithBytes(kCFAllocatorDefault, (unsigned char *)a, 10,27 kCFStringEncodingUTF8, FALSE); // BOOM28 fprintf(stderr, "Ignored.\n");29 free(a);30 CFRelease(str);31}32 33// CHECK-CRASH: AddressSanitizer: heap-buffer-overflow34// CHECK-CRASH-NOT: Ignored.35// CHECK-IGNORE-NOT: AddressSanitizer: heap-buffer-overflow36// CHECK-IGNORE: Ignored.37