blob: 392a65ff5f167ce563da8ed7210719fe48796363 [file] [log] [blame]
Kristof Umann25e592e2019-04-17 19:56:40 +00001// RUN: %clang_analyze_cc1 %s -verify \
2// RUN: -analyzer-checker=security.insecureAPI
Douglas Yung3333cc62019-04-18 00:00:06 +00003// RUN: %clang_analyze_cc1 %s -verify -std=gnu11 \
4// RUN: -analyzer-checker=security.insecureAPI
5// RUN: %clang_analyze_cc1 %s -verify -std=gnu99 \
6// RUN: -analyzer-checker=security.insecureAPI
Kristof Umann25e592e2019-04-17 19:56:40 +00007
8void builtin_function_call_crash_fixes(char *c) {
Douglas Yung3333cc62019-04-18 00:00:06 +00009 __builtin_strncpy(c, "", 6);
10 __builtin_memset(c, '\0', (0));
11 __builtin_memcpy(c, c, 0);
12
13#if __STDC_VERSION__ > 199901
14 // expected-warning@-5{{Call to function 'strncpy' is insecure as it does not provide security checks introduced in the C11 standard.}}
15 // expected-warning@-5{{Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard.}}
16 // expected-warning@-5{{Call to function 'memcpy' is insecure as it does not provide security checks introduced in the C11 standard.}}
17#else
18 // expected-no-diagnostics
19#endif
Kristof Umann25e592e2019-04-17 19:56:40 +000020}