Skip to content

Commit 2801941

Browse files
committed
C++: Never track flow out of an argv argument
This change removes some duplicate results that will otherwise appear due to github#3123 and possibly github#2704.
1 parent 782f2b5 commit 2801941

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cpp/ql/src/semmle/code/cpp/ir/dataflow/DefaultTaintTracking.qll

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,14 @@ private DataFlow::Node getNodeForSource(Expr source) {
6060
(
6161
result = DataFlow::exprNode(source)
6262
or
63-
result = DataFlow::definitionByReferenceNode(source)
63+
// Some of the sources in `isUserInput` are intended to match the value of
64+
// an expression, while others (those modeled below) are intended to match
65+
// the taint that propagates out of an argument, like the `char *` argument
66+
// to `gets`. It's impossible here to tell which is which, but the "access
67+
// to argv" source is definitely not intended to match an output argument,
68+
// and it causes false positives if we let it.
69+
result = DataFlow::definitionByReferenceNode(source) and
70+
not argv(source.(VariableAccess).getTarget())
6471
)
6572
}
6673

0 commit comments

Comments
 (0)