[OptTable] Fix typo VALUE => VALUES (NFCI) (#121523)
[llvm-project.git] / compiler-rt / test / asan / TestCases / strstr-2.c
blob4d00c6e632bbbeb3df111fd088e30f5295ba46b6
1 // Test needle overflow in strstr function
2 // RUN: %clang_asan %s -o %t && %env_asan_opts=strict_string_checks=true not %run %t 2>&1 | FileCheck %s
4 // Test intercept_strstr asan option
5 // Disable other interceptors because strlen may be called inside strstr
6 // RUN: %env_asan_opts=intercept_strstr=false:replace_str=false:intercept_strlen=false %run %t 2>&1
8 #include <assert.h>
9 #include <string.h>
10 #include <sanitizer/asan_interface.h>
12 int main(int argc, char **argv) {
13 char *r = 0;
14 char s1[] = "ab";
15 char s2[4] = "cab";
16 __asan_poison_memory_region ((char *)&s2[2], 2);
17 r = strstr(s1, s2);
18 // CHECK:'s2'{{.*}} <== Memory access at offset {{[0-9]+}} partially overflows this variable
19 assert(r == 0);
20 return 0;