Skip to content

Commit 2c1d7bb

Browse files
Switched to DataFlow::localFlow to avoid false positives.
1 parent 28932e8 commit 2c1d7bb

1 file changed

Lines changed: 4 additions & 24 deletions

File tree

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

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,11 @@ predicate isBoolean( Expr e1 )
3333
)
3434
}
3535

36-
class StringCopyToBooleanConfiguration extends DataFlow::Configuration {
37-
StringCopyToBooleanConfiguration() {
38-
this = "StringCopyToBooleanConfiguration"
39-
}
40-
41-
override predicate isSource(DataFlow::Node source) {
42-
exists( FunctionCall func |
43-
func = source.asExpr()
44-
and isStringComparisonFunction( func.getTarget().getQualifiedName())
45-
)
46-
}
47-
48-
override predicate isSink(DataFlow::Node sink) {
49-
exists( Expr expr1 |
50-
expr1 = sink.asExpr()
51-
and isBoolean( expr1.getConversion*())
52-
)
53-
}
54-
}
55-
5636
predicate isStringCopyCastedAsBoolean( FunctionCall func, Expr expr1, string msg ) {
57-
exists( StringCopyToBooleanConfiguration modeConfig |
58-
modeConfig.hasFlow(DataFlow::exprNode(func), DataFlow::exprNode(expr1))
59-
and msg = "Return Value of " + func.getTarget().getQualifiedName() + " used as boolean."
60-
)
37+
DataFlow::localFlow(DataFlow::exprNode(func), DataFlow::exprNode(expr1))
38+
and isBoolean( expr1.getConversion*())
39+
and isStringComparisonFunction( func.getTarget().getQualifiedName())
40+
and msg = "Return Value of " + func.getTarget().getQualifiedName() + " used as boolean."
6141
}
6242

6343
predicate isStringCopyUsedInCondition( FunctionCall func, Expr expr1, string msg ) {

0 commit comments

Comments
 (0)