зеркало из https://github.com/github/codeql.git
C++: UsingStrcpyAsBoolean.ql: use getName
We agreed in the review of the original PR that `getName` is more appropriate here than `getQualifiedName`. Using `getName` ensures that we also match the `std::`-prefixed versions of these functions as well as user-defined versions.
This commit is contained in:
Родитель
aa0f2f2da3
Коммит
92fbea4e41
|
@ -36,12 +36,12 @@ predicate isBoolean(Expr e1) {
|
|||
predicate isStringCopyCastedAsBoolean(FunctionCall func, Expr expr1, string msg) {
|
||||
DataFlow::localFlow(DataFlow::exprNode(func), DataFlow::exprNode(expr1)) and
|
||||
isBoolean(expr1.getConversion*()) and
|
||||
isStringComparisonFunction(func.getTarget().getQualifiedName()) and
|
||||
msg = "Return value of " + func.getTarget().getQualifiedName() + " used as Boolean."
|
||||
isStringComparisonFunction(func.getTarget().getName()) and
|
||||
msg = "Return value of " + func.getTarget().getName() + " used as Boolean."
|
||||
}
|
||||
|
||||
predicate isStringCopyUsedInLogicalOperationOrCondition(FunctionCall func, Expr expr1, string msg) {
|
||||
isStringComparisonFunction(func.getTarget().getQualifiedName()) and
|
||||
isStringComparisonFunction(func.getTarget().getName()) and
|
||||
(
|
||||
(
|
||||
// it is being used in an equality or logical operation
|
||||
|
@ -60,7 +60,7 @@ predicate isStringCopyUsedInLogicalOperationOrCondition(FunctionCall func, Expr
|
|||
func = ble.getAnOperand()
|
||||
)
|
||||
) and
|
||||
msg = "Return value of " + func.getTarget().getQualifiedName() +
|
||||
msg = "Return value of " + func.getTarget().getName() +
|
||||
" used in a logical operation."
|
||||
or
|
||||
// or the string copy function is used directly as the conditional expression
|
||||
|
@ -75,7 +75,7 @@ predicate isStringCopyUsedInLogicalOperationOrCondition(FunctionCall func, Expr
|
|||
func = ce.getCondition()
|
||||
)
|
||||
) and
|
||||
msg = "Return value of " + func.getTarget().getQualifiedName() +
|
||||
msg = "Return value of " + func.getTarget().getName() +
|
||||
" used directly in a conditional expression."
|
||||
)
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче