Skip to content

Commit 470abfd

Browse files
committed
C++: Conflate iterator value and indirection for taint-flow to fix AST dataflow.
1 parent 962b651 commit 470abfd

File tree

1 file changed

+12
-2
lines changed
  • cpp/ql/lib/semmle/code/cpp/models/implementations

1 file changed

+12
-2
lines changed

cpp/ql/lib/semmle/code/cpp/models/implementations/StdSet.qll

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ private class StdSetConstructor extends Constructor, TaintFunction {
2727

2828
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
2929
// taint flow from any parameter of an iterator type to the qualifier
30-
input.isParameterDeref(this.getAnIteratorParameterIndex()) and
30+
(
31+
// AST dataflow doesn't have indirection for iterators.
32+
// Once we deprecate AST dataflow we can delete this first disjunct.
33+
input.isParameter(this.getAnIteratorParameterIndex()) or
34+
input.isParameterDeref(this.getAnIteratorParameterIndex())
35+
) and
3136
(
3237
output.isReturnValue() // TODO: this is only needed for AST data flow, which treats constructors as returning the new object
3338
or
@@ -45,7 +50,12 @@ private class StdSetInsert extends TaintFunction {
4550
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
4651
// flow from last parameter to qualifier and return value
4752
// (where the return value is a pair, this should really flow just to the first part of it)
48-
input.isParameterDeref(this.getNumberOfParameters() - 1) and
53+
(
54+
// AST dataflow doesn't have indirection for iterators.
55+
// Once we deprecate AST dataflow we can delete this first disjunct.
56+
input.isParameter(this.getNumberOfParameters() - 1) or
57+
input.isParameterDeref(this.getNumberOfParameters() - 1)
58+
) and
4959
(
5060
output.isQualifierObject() or
5161
output.isReturnValue()

0 commit comments

Comments
 (0)