Skip to content

Commit 48d2bd6

Browse files
committed
C++: Improve suppression of duplicate sources
This fixes a cosmetic bug in `.../CWE-134/.../examples.c` in the internal repo.
1 parent 3a89f43 commit 48d2bd6

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ private DataFlow::Node getNodeForSource(Expr source) {
6767
// to `gets`. It's impossible here to tell which is which, but the "access
6868
// to argv" source is definitely not intended to match an output argument,
6969
// and it causes false positives if we let it.
70+
//
71+
// This case goes together with the similar (but not identical) rule in
72+
// `nodeIsBarrierIn`.
7073
result = DataFlow::definitionByReferenceNode(source) and
7174
not argv(source.(VariableAccess).getTarget())
7275
)
@@ -179,7 +182,13 @@ private predicate nodeIsBarrier(DataFlow::Node node) {
179182

180183
private predicate nodeIsBarrierIn(DataFlow::Node node) {
181184
// don't use dataflow into taint sources, as this leads to duplicate results.
182-
node = getNodeForSource(any(Expr e))
185+
exists(Expr source | isUserInput(source, _) |
186+
node = DataFlow::exprNode(source)
187+
or
188+
// This case goes together with the similar (but not identical) rule in
189+
// `getNodeForSource`.
190+
node = DataFlow::definitionByReferenceNode(source)
191+
)
183192
}
184193

185194
cached

0 commit comments

Comments
 (0)