2015-05-28 17:24:33 +08:00
|
|
|
// Test stopset overflow in strspn function
|
2015-08-13 07:50:12 +08:00
|
|
|
// RUN: %clang_asan %s -o %t && %env_asan_opts=strict_string_checks=true not %run %t 2>&1 | FileCheck %s
|
2015-05-28 17:24:33 +08:00
|
|
|
|
|
|
|
// Test intercept_strspn asan option
|
2015-08-13 07:50:12 +08:00
|
|
|
// RUN: %env_asan_opts=intercept_strspn=false %run %t 2>&1
|
2015-05-28 17:24:33 +08:00
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <string.h>
|
2015-10-22 16:10:56 +08:00
|
|
|
#include <sanitizer/asan_interface.h>
|
2015-05-28 17:24:33 +08:00
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
size_t r;
|
2015-06-10 15:16:02 +08:00
|
|
|
char s1[] = "bbc";
|
2015-10-22 16:10:56 +08:00
|
|
|
char s2[5] = "abcd";
|
|
|
|
__asan_poison_memory_region ((char *)&s2[3], 2);
|
2015-05-28 17:24:33 +08:00
|
|
|
r = strspn(s1, s2);
|
2017-03-30 08:41:09 +08:00
|
|
|
// CHECK:'s2'{{.*}} <== Memory access at offset {{[0-9]+}} partially overflows this variable
|
2015-06-10 15:16:02 +08:00
|
|
|
assert(r >= 2);
|
2015-05-28 17:24:33 +08:00
|
|
|
return 0;
|
|
|
|
}
|