Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 92fbea4

Browse files
committed
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.
1 parent aa0f2f2 commit 92fbea4

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

cpp/ql/src/Likely Bugs/Likely Typos/UsingStrcpyAsBoolean.ql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ predicate isBoolean(Expr e1) {
3636
predicate isStringCopyCastedAsBoolean(FunctionCall func, Expr expr1, string msg) {
3737
DataFlow::localFlow(DataFlow::exprNode(func), DataFlow::exprNode(expr1)) and
3838
isBoolean(expr1.getConversion*()) and
39-
isStringComparisonFunction(func.getTarget().getQualifiedName()) and
40-
msg = "Return value of " + func.getTarget().getQualifiedName() + " used as Boolean."
39+
isStringComparisonFunction(func.getTarget().getName()) and
40+
msg = "Return value of " + func.getTarget().getName() + " used as Boolean."
4141
}
4242

4343
predicate isStringCopyUsedInLogicalOperationOrCondition(FunctionCall func, Expr expr1, string msg) {
44-
isStringComparisonFunction(func.getTarget().getQualifiedName()) and
44+
isStringComparisonFunction(func.getTarget().getName()) and
4545
(
4646
(
4747
// it is being used in an equality or logical operation
@@ -60,7 +60,7 @@ predicate isStringCopyUsedInLogicalOperationOrCondition(FunctionCall func, Expr
6060
func = ble.getAnOperand()
6161
)
6262
) and
63-
msg = "Return value of " + func.getTarget().getQualifiedName() +
63+
msg = "Return value of " + func.getTarget().getName() +
6464
" used in a logical operation."
6565
or
6666
// or the string copy function is used directly as the conditional expression
@@ -75,7 +75,7 @@ predicate isStringCopyUsedInLogicalOperationOrCondition(FunctionCall func, Expr
7575
func = ce.getCondition()
7676
)
7777
) and
78-
msg = "Return value of " + func.getTarget().getQualifiedName() +
78+
msg = "Return value of " + func.getTarget().getName() +
7979
" used directly in a conditional expression."
8080
)
8181
}

0 commit comments

Comments
 (0)