blob: 53b77e13d91eaa2db7107ab2ee61b7764dea1b9a [file] [log] [blame]
Dan Liew0faaa992018-03-08 21:50:22 +00001// RUN: %clangxx_asan -O0 %s -o %t
2// RUN: not %run %t 2>&1 | FileCheck %s
3// RUN: echo "interceptor_via_fun:bad_function" > %t.supp
4// RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t
5// RUN: echo "interceptor_name:strcpy" > %t.supp
6// RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t
7//
8// RUN: %clangxx_asan -O1 %s -o %t
9// RUN: not %run %t 2>&1 | FileCheck %s
10// RUN: echo "interceptor_via_fun:bad_function" > %t.supp
11// RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t
12// RUN: echo "interceptor_name:strcpy" > %t.supp
13// RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t
14//
15// RUN: %clangxx_asan -O2 %s -o %t
16// RUN: not %run %t 2>&1 | FileCheck %s
17// RUN: echo "interceptor_via_fun:bad_function" > %t.supp
18// RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t
19// RUN: echo "interceptor_name:strcpy" > %t.supp
20// RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t
21//
22// RUN: %clangxx_asan -O3 %s -o %t
23// RUN: not %run %t 2>&1 | FileCheck %s
24// RUN: echo "interceptor_via_fun:bad_function" > %t.supp
25// RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t
26// RUN: echo "interceptor_name:strcpy" > %t.supp
27// RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t
28
Kuba Mracekffb50142018-03-09 00:41:29 +000029// UNSUPPORTED: android
30
Dan Liew0faaa992018-03-08 21:50:22 +000031#include <string.h>
32
33
34// Don't inline function otherwise stacktrace changes.
35__attribute__((noinline)) void bad_function() {
36 char buffer[] = "hello";
37 // CHECK: strcpy-param-overlap: memory ranges
38 // CHECK: [{{0x.*,[ ]*0x.*}}) and [{{0x.*,[ ]*0x.*}}) overlap
39 // CHECK: {{#0 0x.* in .*strcpy}}
40 // CHECK: {{#1 0x.* in bad_function.*strcpy-overlap.cc:}}[[@LINE+2]]
41 // CHECK: {{#2 0x.* in main .*strcpy-overlap.cc:}}[[@LINE+5]]
42 strcpy(buffer, buffer + 1); // BOOM
43}
44
45int main(int argc, char **argv) {
46 bad_function();
47 return 0;
48}