Skip to content

Commit 865d91d

Browse files
committed
C++: Fix getAValueTypeParameterIndex().
1 parent 816b8ab commit 865d91d

File tree

5 files changed

+6
-3
lines changed

5 files changed

+6
-3
lines changed

cpp/ql/src/semmle/code/cpp/models/implementations/StdContainer.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ class StdSequenceContainerAssign extends TaintFunction {
101101
* value type of the container.
102102
*/
103103
int getAValueTypeParameterIndex() {
104-
getParameter(result).getUnspecifiedType() = getDeclaringType().getTemplateArgument(0) // i.e. the `T` of this `std::vector<T>`
104+
getParameter(result).getUnspecifiedType() = getDeclaringType().getTemplateArgument(0).(Type).getUnspecifiedType() // i.e. the `T` of this `std::vector<T>`
105105
or
106106
getParameter(result).getUnspecifiedType().(ReferenceType).getBaseType() =
107-
getDeclaringType().getTemplateArgument(0)
107+
getDeclaringType().getTemplateArgument(0).(Type).getUnspecifiedType()
108108
}
109109

110110
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {

cpp/ql/test/library-tests/dataflow/taint-tests/localTaint.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2325,6 +2325,7 @@
23252325
| vector.cpp:270:18:270:35 | call to source | vector.cpp:270:3:270:4 | ref arg v8 | TAINT |
23262326
| vector.cpp:271:3:271:4 | ref arg v9 | vector.cpp:275:8:275:9 | v9 | |
23272327
| vector.cpp:271:3:271:4 | ref arg v9 | vector.cpp:276:2:276:2 | v9 | |
2328+
| vector.cpp:271:18:271:34 | call to source | vector.cpp:271:3:271:4 | ref arg v9 | TAINT |
23282329
| vector.cpp:273:8:273:9 | ref arg v7 | vector.cpp:276:2:276:2 | v7 | |
23292330
| vector.cpp:274:8:274:9 | ref arg v8 | vector.cpp:276:2:276:2 | v8 | |
23302331
| vector.cpp:275:8:275:9 | ref arg v9 | vector.cpp:276:2:276:2 | v9 | |

cpp/ql/test/library-tests/dataflow/taint-tests/taint.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@
245245
| vector.cpp:243:7:243:8 | v3 | vector.cpp:239:15:239:20 | call to source |
246246
| vector.cpp:273:8:273:9 | v7 | vector.cpp:269:18:269:31 | call to source |
247247
| vector.cpp:274:8:274:9 | v8 | vector.cpp:270:18:270:35 | call to source |
248+
| vector.cpp:275:8:275:9 | v9 | vector.cpp:271:18:271:34 | call to source |
248249
| vector.cpp:285:7:285:8 | v1 | vector.cpp:284:15:284:20 | call to source |
249250
| vector.cpp:286:10:286:13 | call to data | vector.cpp:284:15:284:20 | call to source |
250251
| vector.cpp:287:7:287:18 | access to array | vector.cpp:284:15:284:20 | call to source |

cpp/ql/test/library-tests/dataflow/taint-tests/test_diff.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@
181181
| vector.cpp:243:7:243:8 | vector.cpp:239:15:239:20 | AST only |
182182
| vector.cpp:273:8:273:9 | vector.cpp:269:18:269:31 | AST only |
183183
| vector.cpp:274:8:274:9 | vector.cpp:270:18:270:35 | AST only |
184+
| vector.cpp:275:8:275:9 | vector.cpp:271:18:271:34 | AST only |
184185
| vector.cpp:285:7:285:8 | vector.cpp:284:15:284:20 | AST only |
185186
| vector.cpp:286:10:286:13 | vector.cpp:284:15:284:20 | AST only |
186187
| vector.cpp:287:7:287:18 | vector.cpp:284:15:284:20 | AST only |

cpp/ql/test/library-tests/dataflow/taint-tests/vector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ void test_vector_assign() {
272272

273273
sink(v7); // tainted
274274
sink(v8); // tainted
275-
sink(v9); // tainted [NOT DETECTED]
275+
sink(v9); // tainted
276276
}
277277
}
278278

0 commit comments

Comments
 (0)