summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test/asan/TestCases/stack-buffer-overflow.cpp
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2019-08-05 16:48:12 +0000
committerNico Weber <nicolasweber@gmx.de>2019-08-05 16:48:12 +0000
commit673dc3d4a0b0fbb3b9b34ae2ecbfa522627fe582 (patch)
tree93e9f9c3508af096ba717ef85186950135b4c225 /compiler-rt/test/asan/TestCases/stack-buffer-overflow.cpp
parenta96cfee98a22e262367868f343b599c2312149b7 (diff)
downloadbcm5719-llvm-673dc3d4a0b0fbb3b9b34ae2ecbfa522627fe582.tar.gz
bcm5719-llvm-673dc3d4a0b0fbb3b9b34ae2ecbfa522627fe582.zip
compiler-rt: Rename cc files below test/asan to cpp
See r367803 and similar other changes. llvm-svn: 367887
Diffstat (limited to 'compiler-rt/test/asan/TestCases/stack-buffer-overflow.cpp')
-rw-r--r--compiler-rt/test/asan/TestCases/stack-buffer-overflow.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/compiler-rt/test/asan/TestCases/stack-buffer-overflow.cpp b/compiler-rt/test/asan/TestCases/stack-buffer-overflow.cpp
new file mode 100644
index 00000000000..07cf39433b4
--- /dev/null
+++ b/compiler-rt/test/asan/TestCases/stack-buffer-overflow.cpp
@@ -0,0 +1,16 @@
+// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s
+
+#include <string.h>
+int main(int argc, char **argv) {
+ char x[10];
+ memset(x, 0, 10);
+ int res = x[argc * 10]; // BOOOM
+ // CHECK: {{READ of size 1 at 0x.* thread T0}}
+ // CHECK: {{ #0 0x.* in main .*stack-buffer-overflow.cpp:}}[[@LINE-2]]
+ // CHECK: {{Address 0x.* is located in stack of thread T0 at offset}}
+ // CHECK-NEXT: in{{.*}}main{{.*}}stack-buffer-overflow.cpp
+ return res;
+}
OpenPOWER on IntegriCloud