[clang] [clang][analyzer] Support `fprintf` in the SecuritySyntaxChecker (PR #73247)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 23 07:01:06 PST 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 0bc7cd4d51226344a54da5929d87184730e73e83 150d3374346ef2f09e4c656614c2cccc83771083 -- clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp clang/test/Analysis/security-syntax-checks.c
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp b/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
index e96f8f131e..dbba12bb43 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
@@ -144,38 +144,39 @@ void WalkAST::VisitCallExpr(CallExpr *CE) {
Name = Name.substr(10);
// Set the evaluation function by switching on the callee name.
- FnCheck evalFunction = llvm::StringSwitch<FnCheck>(Name)
- .Case("bcmp", &WalkAST::checkCall_bcmp)
- .Case("bcopy", &WalkAST::checkCall_bcopy)
- .Case("bzero", &WalkAST::checkCall_bzero)
- .Case("gets", &WalkAST::checkCall_gets)
- .Case("getpw", &WalkAST::checkCall_getpw)
- .Case("mktemp", &WalkAST::checkCall_mktemp)
- .Case("mkstemp", &WalkAST::checkCall_mkstemp)
- .Case("mkdtemp", &WalkAST::checkCall_mkstemp)
- .Case("mkstemps", &WalkAST::checkCall_mkstemp)
- .Cases("strcpy", "__strcpy_chk", &WalkAST::checkCall_strcpy)
- .Cases("strcat", "__strcat_chk", &WalkAST::checkCall_strcat)
- .Cases("sprintf", "vsprintf", "scanf", "wscanf", "fscanf", "fwscanf",
- "vscanf", "vwscanf", "vfscanf", "vfwscanf",
- &WalkAST::checkDeprecatedOrUnsafeBufferHandling)
- .Cases("sscanf", "swscanf", "vsscanf", "vswscanf", "swprintf",
- "snprintf", "vswprintf", "vsnprintf", "memcpy", "memmove",
- &WalkAST::checkDeprecatedOrUnsafeBufferHandling)
- .Cases("strncpy", "strncat", "memset", "fprintf",
- &WalkAST::checkDeprecatedOrUnsafeBufferHandling)
- .Case("drand48", &WalkAST::checkCall_rand)
- .Case("erand48", &WalkAST::checkCall_rand)
- .Case("jrand48", &WalkAST::checkCall_rand)
- .Case("lrand48", &WalkAST::checkCall_rand)
- .Case("mrand48", &WalkAST::checkCall_rand)
- .Case("nrand48", &WalkAST::checkCall_rand)
- .Case("lcong48", &WalkAST::checkCall_rand)
- .Case("rand", &WalkAST::checkCall_rand)
- .Case("rand_r", &WalkAST::checkCall_rand)
- .Case("random", &WalkAST::checkCall_random)
- .Case("vfork", &WalkAST::checkCall_vfork)
- .Default(nullptr);
+ FnCheck evalFunction =
+ llvm::StringSwitch<FnCheck>(Name)
+ .Case("bcmp", &WalkAST::checkCall_bcmp)
+ .Case("bcopy", &WalkAST::checkCall_bcopy)
+ .Case("bzero", &WalkAST::checkCall_bzero)
+ .Case("gets", &WalkAST::checkCall_gets)
+ .Case("getpw", &WalkAST::checkCall_getpw)
+ .Case("mktemp", &WalkAST::checkCall_mktemp)
+ .Case("mkstemp", &WalkAST::checkCall_mkstemp)
+ .Case("mkdtemp", &WalkAST::checkCall_mkstemp)
+ .Case("mkstemps", &WalkAST::checkCall_mkstemp)
+ .Cases("strcpy", "__strcpy_chk", &WalkAST::checkCall_strcpy)
+ .Cases("strcat", "__strcat_chk", &WalkAST::checkCall_strcat)
+ .Cases("sprintf", "vsprintf", "scanf", "wscanf", "fscanf", "fwscanf",
+ "vscanf", "vwscanf", "vfscanf", "vfwscanf",
+ &WalkAST::checkDeprecatedOrUnsafeBufferHandling)
+ .Cases("sscanf", "swscanf", "vsscanf", "vswscanf", "swprintf",
+ "snprintf", "vswprintf", "vsnprintf", "memcpy", "memmove",
+ &WalkAST::checkDeprecatedOrUnsafeBufferHandling)
+ .Cases("strncpy", "strncat", "memset", "fprintf",
+ &WalkAST::checkDeprecatedOrUnsafeBufferHandling)
+ .Case("drand48", &WalkAST::checkCall_rand)
+ .Case("erand48", &WalkAST::checkCall_rand)
+ .Case("jrand48", &WalkAST::checkCall_rand)
+ .Case("lrand48", &WalkAST::checkCall_rand)
+ .Case("mrand48", &WalkAST::checkCall_rand)
+ .Case("nrand48", &WalkAST::checkCall_rand)
+ .Case("lcong48", &WalkAST::checkCall_rand)
+ .Case("rand", &WalkAST::checkCall_rand)
+ .Case("rand_r", &WalkAST::checkCall_rand)
+ .Case("random", &WalkAST::checkCall_random)
+ .Case("vfork", &WalkAST::checkCall_vfork)
+ .Default(nullptr);
// If the callee isn't defined, it is not of security concern.
// Check and evaluate the call.
``````````
</details>
https://github.com/llvm/llvm-project/pull/73247
More information about the cfe-commits
mailing list