]> git.proxmox.com Git - rustc.git/blob - src/libcompiler_builtins/compiler-rt/test/asan/TestCases/strpbrk-2.c
New upstream version 1.25.0+dfsg1
[rustc.git] / src / libcompiler_builtins / compiler-rt / test / asan / TestCases / strpbrk-2.c
1 // Test stopset overflow in strpbrk 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_strpbrk asan option
5 // RUN: %env_asan_opts=intercept_strpbrk=false %run %t 2>&1
6
7 #include <assert.h>
8 #include <string.h>
9 #include <sanitizer/asan_interface.h>
10
11 int main(int argc, char **argv) {
12 char *r;
13 char s1[] = "c";
14 char s2[4] = "bca";
15 __asan_poison_memory_region ((char *)&s2[2], 2);
16 r = strpbrk(s1, s2);
17 // CHECK:'s2'{{.*}} <== Memory access at offset {{[0-9]+}} partially overflows this variable
18 assert(r == s1);
19 return 0;
20 }