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:
Jonas Jensen 2019-01-09 14:18:45 +01:00
Родитель aa0f2f2da3
Коммит 92fbea4e41
1 изменённых файлов: 5 добавлений и 5 удалений

Просмотреть файл

@ -36,12 +36,12 @@ predicate isBoolean(Expr e1) {
predicate isStringCopyCastedAsBoolean(FunctionCall func, Expr expr1, string msg) { predicate isStringCopyCastedAsBoolean(FunctionCall func, Expr expr1, string msg) {
DataFlow::localFlow(DataFlow::exprNode(func), DataFlow::exprNode(expr1)) and DataFlow::localFlow(DataFlow::exprNode(func), DataFlow::exprNode(expr1)) and
isBoolean(expr1.getConversion*()) and isBoolean(expr1.getConversion*()) and
isStringComparisonFunction(func.getTarget().getQualifiedName()) and isStringComparisonFunction(func.getTarget().getName()) and
msg = "Return value of " + func.getTarget().getQualifiedName() + " used as Boolean." msg = "Return value of " + func.getTarget().getName() + " used as Boolean."
} }
predicate isStringCopyUsedInLogicalOperationOrCondition(FunctionCall func, Expr expr1, string msg) { 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 // it is being used in an equality or logical operation
@ -60,7 +60,7 @@ predicate isStringCopyUsedInLogicalOperationOrCondition(FunctionCall func, Expr
func = ble.getAnOperand() func = ble.getAnOperand()
) )
) and ) and
msg = "Return value of " + func.getTarget().getQualifiedName() + msg = "Return value of " + func.getTarget().getName() +
" used in a logical operation." " used in a logical operation."
or or
// or the string copy function is used directly as the conditional expression // or the string copy function is used directly as the conditional expression
@ -75,7 +75,7 @@ predicate isStringCopyUsedInLogicalOperationOrCondition(FunctionCall func, Expr
func = ce.getCondition() func = ce.getCondition()
) )
) and ) and
msg = "Return value of " + func.getTarget().getQualifiedName() + msg = "Return value of " + func.getTarget().getName() +
" used directly in a conditional expression." " used directly in a conditional expression."
) )
} }