Kristof Umann | 25e592e | 2019-04-17 19:56:40 +0000 | [diff] [blame] | 1 | // RUN: %clang_analyze_cc1 %s -verify \ |
| 2 | // RUN: -analyzer-checker=security.insecureAPI |
Douglas Yung | 3333cc6 | 2019-04-18 00:00:06 +0000 | [diff] [blame] | 3 | // 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 Umann | 25e592e | 2019-04-17 19:56:40 +0000 | [diff] [blame] | 7 | |
| 8 | void builtin_function_call_crash_fixes(char *c) { |
Douglas Yung | 3333cc6 | 2019-04-18 00:00:06 +0000 | [diff] [blame] | 9 | __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 Umann | 25e592e | 2019-04-17 19:56:40 +0000 | [diff] [blame] | 20 | } |