brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · af78bc4 Raw
56 lines · cpp
1// RUN: %clangxx_asan -O0 -fno-builtin %s -o %t2// RUN: not %run %t 2>&1 | FileCheck %s3// RUN: echo "interceptor_via_fun:bad_function" > %t.supp4// RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t5// RUN: echo "interceptor_name:strcat" > %t.supp6// RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t7//8// RUN: %clangxx_asan -O1 -fno-builtin %s -o %t9// RUN: not %run %t 2>&1 | FileCheck %s10// RUN: echo "interceptor_via_fun:bad_function" > %t.supp11// RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t12// RUN: echo "interceptor_name:strcat" > %t.supp13// RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t14//15// RUN: %clangxx_asan -O2 -fno-builtin %s -o %t16// RUN: not %run %t 2>&1 | FileCheck %s17// RUN: echo "interceptor_via_fun:bad_function" > %t.supp18// RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t19// RUN: echo "interceptor_name:strcat" > %t.supp20// RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t21//22// RUN: %clangxx_asan -O3 -fno-builtin %s -o %t23// RUN: not %run %t 2>&1 | FileCheck %s24// RUN: echo "interceptor_via_fun:bad_function" > %t.supp25// RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t26// RUN: echo "interceptor_name:strcat" > %t.supp27// RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t28 29// This test when run with suppressions invokes undefined30// behavior which can cause all sorts of bad things to happen31// depending on how strcat() is implemented. For now only run32// on platforms where we know the test passes.33// REQUIRES: x86_64h-darwin || x86_64-darwin || i386-darwin || x86_64-linux || i386-linux34// UNSUPPORTED: target={{.*windows-msvc.*}}35// UNSUPPORTED: android36 37#include "defines.h"38#include <string.h>39 40 41// Don't inline function otherwise stacktrace changes.42ATTRIBUTE_NOINLINE void bad_function() {43  char buffer[] = "hello\0XXX";44  // CHECK: strcat-param-overlap: memory ranges45  // CHECK: [{{0x.*,[ ]*0x.*}}) and [{{0x.*,[ ]*0x.*}}) overlap46  // CHECK: {{#0 0x.* in .*strcat}}47  // CHECK: {{#1 0x.* in bad_function.*strcat-overlap.cpp:}}[[@LINE+2]]48  // CHECK: {{#2 0x.* in main .*strcat-overlap.cpp:}}[[@LINE+5]]49  strcat(buffer, buffer + 1); // BOOM50}51 52int main(int argc, char **argv) {53  bad_function();54  return 0;55}56