summaryrefslogtreecommitdiff
path: root/test/asan/TestCases/strpbrk-1.c
diff options
context:
space:
mode:
authorYury Gribov <y.gribov@samsung.com>2015-10-22 08:10:56 +0000
committerYury Gribov <y.gribov@samsung.com>2015-10-22 08:10:56 +0000
commit6db176913c038833047640f591b18f105ac51732 (patch)
treef41de46539ca1b1d15e09e7a7a635c089e5bdf4c /test/asan/TestCases/strpbrk-1.c
parentd6184a3b9865249280fdf03830f4b907855ea842 (diff)
[asan] Get rid of UB in string tests. Patch by Max Ostapenko.
Differential revision: http://reviews.llvm.org/D13895 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@250998 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/asan/TestCases/strpbrk-1.c')
-rw-r--r--test/asan/TestCases/strpbrk-1.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/test/asan/TestCases/strpbrk-1.c b/test/asan/TestCases/strpbrk-1.c
index b7a784d99..626e8777e 100644
--- a/test/asan/TestCases/strpbrk-1.c
+++ b/test/asan/TestCases/strpbrk-1.c
@@ -6,14 +6,15 @@
#include <assert.h>
#include <string.h>
+#include <sanitizer/asan_interface.h>
int main(int argc, char **argv) {
char *r;
char s2[] = "ab";
- char s1[] = {'c', 'a'};
- char s3 = 0;
+ char s1[4] = "cab";
+ __asan_poison_memory_region ((char *)&s1[2], 2);
r = strpbrk(s1, s2);
- // CHECK:'s{{[1|3]}}' <== Memory access at offset {{[0-9]+ .*}}flows this variable
+ // CHECK:'s1' <== Memory access at offset {{[0-9]+}} partially overflows this variable
assert(r == s1 + 1);
return 0;
}