summaryrefslogtreecommitdiff
path: root/test/hwasan/TestCases
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2018-09-12 00:27:34 +0000
committerKostya Serebryany <kcc@google.com>2018-09-12 00:27:34 +0000
commite3814b0505259c0963f9501d52d893abba507084 (patch)
treeb49d3bdd1603b8dff8cc7e0284de25e4d9f00008 /test/hwasan/TestCases
parentcd1fe50e553bb02a3a33abf01babaecfa4f1319c (diff)
downloadcompiler-rt-e3814b0505259c0963f9501d52d893abba507084.tar.gz
[hwasan] tests for a buffer overflow with a large allocation
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@342011 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/hwasan/TestCases')
-rw-r--r--test/hwasan/TestCases/heap-buffer-overflow.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/test/hwasan/TestCases/heap-buffer-overflow.c b/test/hwasan/TestCases/heap-buffer-overflow.c
index b5d10def3..40b6e6e9d 100644
--- a/test/hwasan/TestCases/heap-buffer-overflow.c
+++ b/test/hwasan/TestCases/heap-buffer-overflow.c
@@ -2,6 +2,8 @@
// RUN: not %run %t 40 2>&1 | FileCheck %s --check-prefix=CHECK40
// RUN: not %run %t 80 2>&1 | FileCheck %s --check-prefix=CHECK80
// RUN: not %run %t -30 2>&1 | FileCheck %s --check-prefix=CHECKm30
+// RUN: not %run %t -30 1000000 2>&1 | FileCheck %s --check-prefix=CHECKMm30
+// RUN: not %run %t 1000000 1000000 2>&1 | FileCheck %s --check-prefix=CHECKM
// REQUIRES: stable-runtime
@@ -12,10 +14,13 @@
int main(int argc, char **argv) {
__hwasan_enable_allocator_tagging();
int offset = argc < 2 ? 40 : atoi(argv[1]);
- char * volatile x = (char*)malloc(30);
+ int size = argc < 3 ? 30 : atoi(argv[2]);
+ char * volatile x = (char*)malloc(size);
x[offset] = 42;
// CHECK40: is located 10 bytes to the right of 30-byte region
// CHECK80: is located 50 bytes to the right of 30-byte region
// CHECKm30: is located 30 bytes to the left of 30-byte region
+// CHECKMm30: is located 30 bytes to the left of 1000000-byte region
+// CHECKM: is located 0 bytes to the right of 1000000-byte region
free(x);
}