]> granicus.if.org Git - clang/commitdiff
[analyzer] Change the warning to suggest 'strlcat/strlcpy' as
authorAnna Zaks <ganna@apple.com>
Tue, 31 Jan 2012 19:33:31 +0000 (19:33 +0000)
committerAnna Zaks <ganna@apple.com>
Tue, 31 Jan 2012 19:33:31 +0000 (19:33 +0000)
replacements for 'starcat/strcpy' instead of 'strncat/strncpy'.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149406 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
test/Analysis/security-syntax-checks.m

index 0798a296438d3e1a65fc7f006110d2e841f82032..87594ff4a76834383604040da1df675b85480b96 100644 (file)
@@ -516,7 +516,7 @@ void WalkAST::checkCall_strcpy(const CallExpr *CE, const FunctionDecl *FD) {
                      "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 'strncpy'. CWE-119.",
+                    "support length arguments such as 'strlcpy'. CWE-119.",
                      CELoc, &R, 1);
 }
 
@@ -543,7 +543,7 @@ void WalkAST::checkCall_strcat(const CallExpr *CE, const FunctionDecl *FD) {
                     "Call to function 'strcat' 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 'strncat'. CWE-119.",
+                    "support length arguments such as 'strlcat'. CWE-119.",
                      CELoc, &R, 1);
 }
 
index b392bd1ea6824a7f5b6e91d51ca1733ae9aa7b01..f4ccefe58cdbbb024470155e2a5ba12ae50a00ab 100644 (file)
@@ -138,7 +138,7 @@ void test_strcpy() {
   char x[4];
   char *y;
 
-  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 'strncpy'. CWE-119.}}
+  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.}}
 }
 
 //===----------------------------------------------------------------------===
@@ -162,7 +162,7 @@ void test_strcat() {
   char x[4];
   char *y;
 
-  strcat(x, y); //expected-warning{{Call to function 'strcat' 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 'strncat'. CWE-119.}}
+  strcat(x, y); //expected-warning{{Call to function 'strcat' 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 'strlcat'. CWE-119.}}
 }
 
 //===----------------------------------------------------------------------===