summaryrefslogtreecommitdiff
path: root/test/asan/TestCases/strstr-2.c
diff options
context:
space:
mode:
authorYury Gribov <y.gribov@samsung.com>2015-05-28 09:24:33 +0000
committerYury Gribov <y.gribov@samsung.com>2015-05-28 09:24:33 +0000
commitf2fa25015a85f504430864b8038c99995fd3fa95 (patch)
tree5056b4071beab3850d912a359c9d80e3bc500a83 /test/asan/TestCases/strstr-2.c
parentd7d4be4d271a5dc32b2ec0ddb7224f2421225e3e (diff)
[sanitizer] More string interceptors: strstr, strcasestr, strspn, strcspn, strpbrk.
Patch by Maria Guseva. Differential Revision: http://reviews.llvm.org/D9017 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@238406 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/asan/TestCases/strstr-2.c')
-rw-r--r--test/asan/TestCases/strstr-2.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/asan/TestCases/strstr-2.c b/test/asan/TestCases/strstr-2.c
new file mode 100644
index 000000000..1ee36de31
--- /dev/null
+++ b/test/asan/TestCases/strstr-2.c
@@ -0,0 +1,19 @@
+// Test needle overflow in strstr function
+// RUN: %clang_asan %s -o %t && ASAN_OPTIONS=strict_string_checks=true not %run %t 2>&1 | FileCheck %s
+
+// Test intercept_strstr asan option
+// RUN: ASAN_OPTIONS=intercept_strstr=false %run %t 2>&1
+
+#include <assert.h>
+#include <string.h>
+
+int main(int argc, char **argv) {
+ char *r = 0;
+ char s1[] = "ab";
+ char s2[] = {'c'};
+ char s3 = 0;
+ r = strstr(s1, s2);
+ // CHECK:'s{{[2|3]}}' <== Memory access at offset {{[0-9]+ .*}}flows this variable
+ assert(r == 0);
+ return 0;
+}