diff options
| author | Artem Dergachev <artem.dergachev@gmail.com> | 2018-01-12 22:12:11 +0000 |
|---|---|---|
| committer | Artem Dergachev <artem.dergachev@gmail.com> | 2018-01-12 22:12:11 +0000 |
| commit | 1ebd1c4f9d9932b0095e03560b5fab1d5e0ee987 (patch) | |
| tree | dcdfc83d3cc39d6e2efe6c7f446b0dd1e383ce83 /clang/test/Analysis/security-syntax-checks.m | |
| parent | 59e4e400c3ba5a4f7a496a336335f77af581443a (diff) | |
| download | bcm5719-llvm-1ebd1c4f9d9932b0095e03560b5fab1d5e0ee987.tar.gz bcm5719-llvm-1ebd1c4f9d9932b0095e03560b5fab1d5e0ee987.zip | |
[analyzer] Don't flag strcpy of string literals into sufficiently large buffers.
In the security package, we have a simple syntactic check that warns about
strcpy() being insecure, due to potential buffer overflows.
Suppress that check's warning in the trivial situation when the source is an
immediate null-terminated string literal and the target is an immediate
sufficiently large buffer.
Patch by AndrĂ¡s Leitereg!
Differential Revision: https://reviews.llvm.org/D41384
llvm-svn: 322410
Diffstat (limited to 'clang/test/Analysis/security-syntax-checks.m')
| -rw-r--r-- | clang/test/Analysis/security-syntax-checks.m | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/test/Analysis/security-syntax-checks.m b/clang/test/Analysis/security-syntax-checks.m index 04a4c7d8665..8560ba29e70 100644 --- a/clang/test/Analysis/security-syntax-checks.m +++ b/clang/test/Analysis/security-syntax-checks.m @@ -146,6 +146,16 @@ void test_strcpy() { strcpy(x, y); //expected-warning{{Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119}} } +void test_strcpy_2() { + char x[4]; + strcpy(x, "abcd"); //expected-warning{{Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119}} +} + +void test_strcpy_safe() { + char x[5]; + strcpy(x, "abcd"); +} + //===----------------------------------------------------------------------=== // strcat() //===----------------------------------------------------------------------=== |

