aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2012-08-07 18:36:58 +0000
committerAnna Zaks <ganna@apple.com>2012-08-07 18:36:58 +0000
commitd43e114291eed272f8d7b735d3d1c4ca4cd04986 (patch)
tree11fa1144a59151d2ce043d1660623dbc8ad33e20
parent67bf7dd9fa3aaa65c7105f77f265f05f35f235fd (diff)
Turn on strncat-size warning implemented a while ago.
Warns on anti-patterns/typos in the 'size' argument to strncat. The correct size argument should look like the following: - strncat(dst, src, sizeof(dst) - strlen(dest) - 1); We warn on: - sizeof(dst) - sizeof(src) - sizeof(dst) - strlen(dst) - sizeof(src) - anything (This has been implemented in void Sema::CheckStrncatArguments().) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161440 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td4
-rw-r--r--test/Analysis/cstring-syntax.c2
2 files changed, 3 insertions, 3 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index 4d5882f329..566a8f01fa 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -373,9 +373,9 @@ def note_strlcpycat_wrong_size : Note<
def warn_strncat_large_size : Warning<
"the value of the size argument in 'strncat' is too large, might lead to a "
- "buffer overflow">, InGroup<StrncatSize>, DefaultIgnore;
+ "buffer overflow">, InGroup<StrncatSize>, DefaultWarnNoWerror;
def warn_strncat_src_size : Warning<"size argument in 'strncat' call appears "
- "to be size of the source">, InGroup<StrncatSize>, DefaultIgnore;
+ "to be size of the source">, InGroup<StrncatSize>, DefaultWarnNoWerror;
def note_strncat_wrong_size : Note<
"change the argument to be the free space in the destination buffer minus "
"the terminating null byte">;
diff --git a/test/Analysis/cstring-syntax.c b/test/Analysis/cstring-syntax.c
index 64ecb67008..4aa88ed3b7 100644
--- a/test/Analysis/cstring-syntax.c
+++ b/test/Analysis/cstring-syntax.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=unix.cstring.BadSizeArg -analyzer-store=region -Wno-strlcpy-strlcat-size -Wno-sizeof-array-argument -Wno-sizeof-pointer-memaccess -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=unix.cstring.BadSizeArg -analyzer-store=region -Wno-strncat-size -Wno-strlcpy-strlcat-size -Wno-sizeof-array-argument -Wno-sizeof-pointer-memaccess -verify %s
typedef __SIZE_TYPE__ size_t;
char *strncat(char *, const char *, size_t);