diff options
| author | Artem Dergachev <artem.dergachev@gmail.com> | 2019-04-25 20:30:14 +0000 |
|---|---|---|
| committer | Artem Dergachev <artem.dergachev@gmail.com> | 2019-04-25 20:30:14 +0000 |
| commit | ecefce6a49b46551d2a4b3b37d360dde90a32f8d (patch) | |
| tree | f53cdb79fd011588742ab6a95c6b04d3b5d0a8ff | |
| parent | 0c4dbf9ecd32b2719beff4490b1624ef13705a09 (diff) | |
| download | bcm5719-llvm-ecefce6a49b46551d2a4b3b37d360dde90a32f8d.tar.gz bcm5719-llvm-ecefce6a49b46551d2a4b3b37d360dde90a32f8d.zip | |
[analyzer] Add FIXMEs for alpha.unix.cstring.OutOfBounds false positives.
Caused by incorrect strlcat() modeling in r332303,
cf. https://bugs.llvm.org/show_bug.cgi?id=37687#c8
llvm-svn: 359237
| -rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp | 4 | ||||
| -rw-r--r-- | clang/test/Analysis/bsd-string.c | 1 |
2 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp index fe11e54883b..73a5d58d9ee 100644 --- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp @@ -1528,6 +1528,10 @@ void CStringChecker::evalStrlcat(CheckerContext &C, const CallExpr *CE) const { if (CE->getNumArgs() < 3) return; + // FIXME: strlcat() uses a different rule for bound checking, i.e. 'n' means + // a different thing as compared to strncat(). This currently causes + // false positives in the alpha string bound checker. + //char *strlcat(char *s1, const char *s2, size_t n); evalStrcpyCommon(C, CE, /* returnEnd = */ false, diff --git a/clang/test/Analysis/bsd-string.c b/clang/test/Analysis/bsd-string.c index bca42ca8964..4fbfd48ad8a 100644 --- a/clang/test/Analysis/bsd-string.c +++ b/clang/test/Analysis/bsd-string.c @@ -15,6 +15,7 @@ void f1() { void f2() { char buf[5]; strlcpy(buf, "abcd", sizeof(buf)); // expected-no-warning + // FIXME: This should not warn. The string is safely truncated. strlcat(buf, "efgh", sizeof(buf)); // expected-warning{{Size argument is greater than the free space in the destination buffer}} } |

