diff options
author | Kostya Serebryany <kcc@google.com> | 2018-08-31 03:18:31 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2018-08-31 03:18:31 +0000 |
commit | 9eba657efa3311c4b7f2a5deb6ad71fcdeb5711a (patch) | |
tree | 2f39ae728472819016a661fb36ee2e10385f2656 /test/hwasan/TestCases/heap-buffer-overflow.c | |
parent | f19416e3ca507b6b9ebf9d110ba9e00804fb9509 (diff) | |
download | compiler-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.c | 16 |
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); +} |