[CPP-340] Replace whitelist with f.getBlock() test. Fix doc comment.

This commit is contained in:
Ziemowit Laski
2019-04-29 09:58:31 -07:00
parent 4a760b1561
commit a0cfe826ee
2 changed files with 4 additions and 16 deletions

View File

@@ -1,9 +1,8 @@
/**
* @name Call to a function with one or more incompatible arguments
* @description A call to a function with at least one argument whose type does
* not match the type of the corresponding function parameter. This may indicate
* that the author is not familiar with the function being called. Passing mistyped
* arguments on a stack may lead to unpredictable function behavior.
* @description When the type of a function argument is not compatible
* with the type of the corresponding parameter, it may lead to
* unpredictable behavior.
* @kind problem
* @problem.severity warning
* @precision medium

View File

@@ -31,24 +31,13 @@ predicate isCompiledAsC(Function f) {
)
}
predicate isWhitelisted(Function f) {
f instanceof BuiltInFunction
or
// The following list can be expanded as the need arises
exists(string name | name = f.getName() |
name = "static_assert" or
name = "_Static_assert" or
name = "strptime"
)
}
from FunctionCall fc, Function f
where
f = fc.getTarget() and
not f.isVarargs() and
hasZeroParamDecl(f) and
isCompiledAsC(f) and
not isWhitelisted(f) and
exists(f.getBlock()) and
// There must not exist a declaration with the number of parameters
// at least as large as the number of call arguments
not exists(FunctionDeclarationEntry fde | fde = f.getADeclarationEntry() |