[compiler-rt] r341162 - [hwasan] more heap-buffer-overflow tests

Kostya Serebryany via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 30 22:05:02 PDT 2018


Author: kcc
Date: Thu Aug 30 22:05:01 2018
New Revision: 341162

URL: http://llvm.org/viewvc/llvm-project?rev=341162&view=rev
Log:
[hwasan] more heap-buffer-overflow tests

Modified:
    compiler-rt/trunk/test/hwasan/TestCases/heap-buffer-overflow.c

Modified: compiler-rt/trunk/test/hwasan/TestCases/heap-buffer-overflow.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/hwasan/TestCases/heap-buffer-overflow.c?rev=341162&r1=341161&r2=341162&view=diff
==============================================================================
--- compiler-rt/trunk/test/hwasan/TestCases/heap-buffer-overflow.c (original)
+++ compiler-rt/trunk/test/hwasan/TestCases/heap-buffer-overflow.c Thu Aug 30 22:05:01 2018
@@ -1,16 +1,21 @@
-// RUN: %clang_hwasan  %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clang_hwasan  %s -o %t
+// 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
 
 // REQUIRES: stable-runtime
-// TODO: test more cases.
 
 #include <stdlib.h>
 #include <stdio.h>
 #include <sanitizer/hwasan_interface.h>
 
-int main() {
+int main(int argc, char **argv) {
   __hwasan_enable_allocator_tagging();
+  int offset = argc < 2 ? 40 : atoi(argv[1]);
   char * volatile x = (char*)malloc(30);
-  x[40] = 42;
-// CHECK: is located 10 bytes to the right of 30-byte region
+  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
   free(x);
 }




More information about the llvm-commits mailing list