]>
Commit | Line | Data |
---|---|---|
92a42be0 SL |
1 | // Test needle overflow in strcasestr function |
2 | // RUN: %clang_asan %s -o %t && %env_asan_opts=strict_string_checks=true not %run %t 2>&1 | FileCheck %s | |
3 | ||
4 | // Test intercept_strstr asan option | |
5 | // Disable other interceptors because strlen may be called inside strcasestr | |
5bcae85e | 6 | // RUN: %env_asan_opts=intercept_strstr=false:replace_str=false:intercept_strlen=false %run %t 2>&1 |
92a42be0 SL |
7 | |
8 | // There's no interceptor for strcasestr on Windows | |
9 | // XFAIL: win32 | |
10 | ||
11 | #define _GNU_SOURCE | |
12 | #include <assert.h> | |
13 | #include <string.h> | |
14 | #include <sanitizer/asan_interface.h> | |
15 | ||
16 | int main(int argc, char **argv) { | |
17 | char *r = 0; | |
18 | char s1[] = "ab"; | |
19 | char s2[4] = "cba"; | |
20 | __asan_poison_memory_region ((char *)&s2[2], 2); | |
21 | r = strcasestr(s1, s2); | |
22 | assert(r == 0); | |
23 | // CHECK:'s2' <== Memory access at offset {{[0-9]+}} partially overflows this variable | |
24 | return 0; | |
25 | } |