mirror of
https://github.com/github/codeql.git
synced 2025-12-23 12:16:33 +01:00
C++: Make sure we use an indirect sink only for the sinks that receive a
pointer to the data. Also fix a bug where we used 'asExpr' instead of 'asIndirectExpr'.
This commit is contained in:
@@ -39,7 +39,17 @@ class PotentiallyExposedSystemDataConfiguration extends TaintTracking::Configura
|
||||
}
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) {
|
||||
exists(OutputWrite ow | ow.getASource().getAChild*() = sink.asIndirectExpr())
|
||||
exists(OutputWrite ow, Expr child | child = ow.getASource().getAChild*() |
|
||||
// Most sinks receive a pointer as an argument (for example `printf`),
|
||||
// and we use an indirect sink for those.
|
||||
// However, some sinks (for example `puts`) receive receive a single
|
||||
// character as an argument. For those we have to use a direct sink.
|
||||
if
|
||||
child.getUnspecifiedType() instanceof PointerType or
|
||||
child.getUnspecifiedType() instanceof ArrayType
|
||||
then child = sink.asIndirectExpr()
|
||||
else child = sink.asExpr()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ private predicate sqlConnectInfo(FunctionCall source, Expr use) {
|
||||
class SqlConnectInfo extends SystemData {
|
||||
SqlConnectInfo() { sqlConnectInfo(this, _) }
|
||||
|
||||
override DataFlow::Node getAnExpr() { sqlConnectInfo(this, result.asExpr()) }
|
||||
override DataFlow::Node getAnExpr() { sqlConnectInfo(this, result.asIndirectExpr(1)) }
|
||||
|
||||
override predicate isSensitive() { any() }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user