Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 47ab9ba

Browse files
committed
C++: emplace and emplace_back takes its arguments by universal references, so they should also specify flow as indirections.
1 parent 8cf8b70 commit 47ab9ba

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ class StdVectorEmplace extends TaintFunction {
193193
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
194194
// flow from any parameter except the position iterator to qualifier and return value
195195
// (here we assume taint flow from any constructor parameter to the constructed object)
196-
input.isParameter([1 .. getNumberOfParameters() - 1]) and
196+
input.isParameterDeref([1 .. getNumberOfParameters() - 1]) and
197197
(
198198
output.isQualifierObject() or
199199
output.isReturnValue()
@@ -210,7 +210,7 @@ class StdVectorEmplaceBack extends TaintFunction {
210210
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
211211
// flow from any parameter to qualifier
212212
// (here we assume taint flow from any constructor parameter to the constructed object)
213-
input.isParameter([0 .. getNumberOfParameters() - 1]) and
213+
input.isParameterDeref([0 .. getNumberOfParameters() - 1]) and
214214
output.isQualifierObject()
215215
}
216216
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,8 @@ void test_vector_emplace() {
491491
std::vector<int> v1(10), v2(10);
492492

493493
v1.emplace_back(source());
494-
sink(v1); // $ ast MISSING: ir
494+
sink(v1); // $ ast,ir
495495

496496
v2.emplace(v2.begin(), source());
497-
sink(v2); // $ ast MISSING: ir
497+
sink(v2); // $ ast,ir
498498
}

0 commit comments

Comments
 (0)