1*7c3d14c8STreehugger Robot // Test string s1 overflow in strspn function 2*7c3d14c8STreehugger Robot // RUN: %clang_asan %s -o %t && %env_asan_opts=strict_string_checks=true not %run %t 2>&1 | FileCheck %s 3*7c3d14c8STreehugger Robot 4*7c3d14c8STreehugger Robot // Test intercept_strspn asan option 5*7c3d14c8STreehugger Robot // RUN: %env_asan_opts=intercept_strspn=false %run %t 2>&1 6*7c3d14c8STreehugger Robot 7*7c3d14c8STreehugger Robot #include <assert.h> 8*7c3d14c8STreehugger Robot #include <string.h> 9*7c3d14c8STreehugger Robot #include <sanitizer/asan_interface.h> 10*7c3d14c8STreehugger Robot main(int argc,char ** argv)11*7c3d14c8STreehugger Robotint main(int argc, char **argv) { 12*7c3d14c8STreehugger Robot size_t r; 13*7c3d14c8STreehugger Robot char s2[] = "ab"; 14*7c3d14c8STreehugger Robot char s1[4] = "acb"; 15*7c3d14c8STreehugger Robot __asan_poison_memory_region ((char *)&s1[2], 2); 16*7c3d14c8STreehugger Robot r = strspn(s1, s2); 17*7c3d14c8STreehugger Robot // CHECK:'s1' <== Memory access at offset {{[0-9]+}} partially overflows this variable 18*7c3d14c8STreehugger Robot assert(r == 1); 19*7c3d14c8STreehugger Robot return 0; 20*7c3d14c8STreehugger Robot } 21