blob: 5a19222e6bba1382b2fecafd1b2a67dfaa1d8353 [file] [log] [blame]
Pirama Arumuga Nainarcdce50b2015-07-01 12:26:56 -07001// Test string s1 overflow in strcspn function
2// RUN: %clang_asan %s -o %t && ASAN_OPTIONS=strict_string_checks=true not %run %t 2>&1 | FileCheck %s
3
4// Test intercept_strspn asan option
5// RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:intercept_strspn=false %run %t 2>&1
6
7#include <assert.h>
8#include <string.h>
9
10int main(int argc, char **argv) {
11 size_t r;
12 char s2[] = "ab";
13 char s1[] = {'c', 'a'};
14 char s3 = 0;
15 r = strcspn(s1, s2);
16 // CHECK:'s{{[1|3]}}' <== Memory access at offset {{[0-9]+ .*}}flows this variable
17 assert(r == 1);
18 return 0;
19}