summaryrefslogtreecommitdiff
path: root/test/hwasan/TestCases/heap-buffer-overflow.c
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2018-08-31 03:18:31 +0000
committerKostya Serebryany <kcc@google.com>2018-08-31 03:18:31 +0000
commit9eba657efa3311c4b7f2a5deb6ad71fcdeb5711a (patch)
tree2f39ae728472819016a661fb36ee2e10385f2656 /test/hwasan/TestCases/heap-buffer-overflow.c
parentf19416e3ca507b6b9ebf9d110ba9e00804fb9509 (diff)
downloadcompiler-rt-9eba657efa3311c4b7f2a5deb6ad71fcdeb5711a.tar.gz
[hwasan] properly report heap-buffer-overflow
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@341159 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/hwasan/TestCases/heap-buffer-overflow.c')
-rw-r--r--test/hwasan/TestCases/heap-buffer-overflow.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/hwasan/TestCases/heap-buffer-overflow.c b/test/hwasan/TestCases/heap-buffer-overflow.c
new file mode 100644
index 000000000..36c09b294
--- /dev/null
+++ b/test/hwasan/TestCases/heap-buffer-overflow.c
@@ -0,0 +1,16 @@
+// RUN: %clang_hwasan %s -o %t && not %run %t 2>&1 | FileCheck %s
+
+// REQUIRES: stable-runtime
+// TODO: test more cases.
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <sanitizer/hwasan_interface.h>
+
+int main() {
+ __hwasan_enable_allocator_tagging();
+ char * volatile x = (char*)malloc(30);
+ x[40] = 42;
+// CHECK: is located 10 bytes to the right of 30-byte region
+ free(x);
+}