C++: Improve suppression of duplicate sources

This fixes a cosmetic bug in `.../CWE-134/.../examples.c` in the
internal repo.
This commit is contained in:
Jonas Jensen
2020-05-11 14:35:09 +02:00
parent 3a89f43cd6
commit 48d2bd6102

View File

@@ -67,6 +67,9 @@ private DataFlow::Node getNodeForSource(Expr source) {
// to `gets`. It's impossible here to tell which is which, but the "access
// to argv" source is definitely not intended to match an output argument,
// and it causes false positives if we let it.
//
// This case goes together with the similar (but not identical) rule in
// `nodeIsBarrierIn`.
result = DataFlow::definitionByReferenceNode(source) and
not argv(source.(VariableAccess).getTarget())
)
@@ -179,7 +182,13 @@ private predicate nodeIsBarrier(DataFlow::Node node) {
private predicate nodeIsBarrierIn(DataFlow::Node node) {
// don't use dataflow into taint sources, as this leads to duplicate results.
node = getNodeForSource(any(Expr e))
exists(Expr source | isUserInput(source, _) |
node = DataFlow::exprNode(source)
or
// This case goes together with the similar (but not identical) rule in
// `getNodeForSource`.
node = DataFlow::definitionByReferenceNode(source)
)
}
cached