brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 9334a33 Raw
50 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:strncpy" > %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:strncpy" > %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:strncpy" > %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:strncpy" > %t.supp27// RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t28 29// UNSUPPORTED: android30 31#include "defines.h"32#include <string.h>33 34 35// Don't inline function otherwise stacktrace changes.36ATTRIBUTE_NOINLINE void bad_function() {37  char buffer[] = "hello";38  // CHECK: strncpy-param-overlap: memory ranges39  // CHECK: [{{0x.*,[ ]*0x.*}}) and [{{0x.*,[ ]*0x.*}}) overlap40  // CHECK: {{#0 0x.* in .*strncpy}}41  // CHECK: {{#1 0x.* in bad_function.*strncpy-overlap.cpp:}}[[@LINE+2]]42  // CHECK: {{#2 0x.* in main .*strncpy-overlap.cpp:}}[[@LINE+5]]43  strncpy(buffer, buffer + 1, 5); // BOOM44}45 46int main(int argc, char **argv) {47  bad_function();48  return 0;49}50