[PATCH] D47007: [analyzer] CStringChecker fix for strlcpy when no bytes are copied to the dest buffer
David CARLIER via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 22 21:42:29 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rC333060: [analyzer] CStringChecker fix for strlcpy when no bytes are copied to the dest… (authored by devnexen, committed by ).
Repository:
rC Clang
https://reviews.llvm.org/D47007
Files:
lib/StaticAnalyzer/Checkers/CStringChecker.cpp
test/Analysis/bsd-string.c
Index: lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -1652,7 +1652,11 @@
// If the size is known to be zero, we're done.
if (StateZeroSize && !StateNonZeroSize) {
- StateZeroSize = StateZeroSize->BindExpr(CE, LCtx, DstVal);
+ if (returnPtr) {
+ StateZeroSize = StateZeroSize->BindExpr(CE, LCtx, DstVal);
+ } else {
+ StateZeroSize = StateZeroSize->BindExpr(CE, LCtx, *lenValNL);
+ }
C.addTransition(StateZeroSize);
return;
}
Index: test/Analysis/bsd-string.c
===================================================================
--- test/Analysis/bsd-string.c
+++ test/Analysis/bsd-string.c
@@ -38,3 +38,8 @@
size_t len = strlcat(buf, "defg", 4);
clang_analyzer_eval(len == 7); // expected-warning{{TRUE}}
}
+
+int f7() {
+ char buf[8];
+ return strlcpy(buf, "1234567", 0); // no-crash
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47007.148155.patch
Type: text/x-patch
Size: 1079 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180523/03a0213f/attachment.bin>
More information about the cfe-commits
mailing list