mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
[CPP-340] Replace whitelist with f.getBlock() test. Fix doc comment.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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() |
|
||||
|
||||
Reference in New Issue
Block a user