Skip to content

Commit 1f1be3b

Browse files
committed
C++: Block try_emplace arg 0.
1 parent 8786fe1 commit 1f1be3b

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,10 @@ class StdMapTryEmplace extends TaintFunction {
8181
// flow from any parameter apart from the key to qualifier and return value
8282
// (here we assume taint flow from any constructor parameter to the constructed object)
8383
// (where the return value is a pair, this should really flow just to the first part of it)
84-
exists(int arg | arg = [0 .. getNumberOfParameters() - 1] |
84+
exists(int arg | arg = [1 .. getNumberOfParameters() - 1] |
8585
(
86-
getUnspecifiedType() instanceof Iterator and arg != 1
87-
or
88-
not getUnspecifiedType() instanceof Iterator and arg != 0
86+
not getUnspecifiedType() instanceof Iterator or
87+
arg != 1
8988
) and
9089
input.isParameterDeref(arg)
9190
) and

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,8 +1199,6 @@
11991199
| map.cpp:248:23:248:25 | ref arg m27 | map.cpp:250:23:250:25 | m27 | |
12001200
| map.cpp:248:23:248:25 | ref arg m27 | map.cpp:251:7:251:9 | m27 | |
12011201
| map.cpp:248:23:248:25 | ref arg m27 | map.cpp:252:1:252:1 | m27 | |
1202-
| map.cpp:248:23:248:33 | call to iterator | map.cpp:248:7:248:9 | ref arg m27 | TAINT |
1203-
| map.cpp:248:23:248:33 | call to iterator | map.cpp:248:11:248:21 | call to try_emplace | TAINT |
12041202
| map.cpp:248:27:248:31 | call to begin | map.cpp:248:23:248:33 | call to iterator | TAINT |
12051203
| map.cpp:248:43:248:47 | def | map.cpp:248:7:248:9 | ref arg m27 | TAINT |
12061204
| map.cpp:248:43:248:47 | def | map.cpp:248:11:248:21 | call to try_emplace | TAINT |
@@ -1211,8 +1209,6 @@
12111209
| map.cpp:250:23:250:25 | ref arg m27 | map.cpp:250:7:250:9 | m27 | |
12121210
| map.cpp:250:23:250:25 | ref arg m27 | map.cpp:251:7:251:9 | m27 | |
12131211
| map.cpp:250:23:250:25 | ref arg m27 | map.cpp:252:1:252:1 | m27 | |
1214-
| map.cpp:250:23:250:33 | call to iterator | map.cpp:250:7:250:9 | ref arg m27 | TAINT |
1215-
| map.cpp:250:23:250:33 | call to iterator | map.cpp:250:11:250:21 | call to try_emplace | TAINT |
12161212
| map.cpp:250:27:250:31 | call to begin | map.cpp:250:23:250:33 | call to iterator | TAINT |
12171213
| map.cpp:250:43:250:48 | call to source | map.cpp:250:7:250:9 | ref arg m27 | TAINT |
12181214
| map.cpp:250:43:250:48 | call to source | map.cpp:250:11:250:21 | call to try_emplace | TAINT |
@@ -1872,8 +1868,6 @@
18721868
| map.cpp:399:23:399:25 | ref arg m27 | map.cpp:401:23:401:25 | m27 | |
18731869
| map.cpp:399:23:399:25 | ref arg m27 | map.cpp:402:7:402:9 | m27 | |
18741870
| map.cpp:399:23:399:25 | ref arg m27 | map.cpp:422:1:422:1 | m27 | |
1875-
| map.cpp:399:23:399:33 | call to iterator | map.cpp:399:7:399:9 | ref arg m27 | TAINT |
1876-
| map.cpp:399:23:399:33 | call to iterator | map.cpp:399:11:399:21 | call to try_emplace | TAINT |
18771871
| map.cpp:399:27:399:31 | call to begin | map.cpp:399:23:399:33 | call to iterator | TAINT |
18781872
| map.cpp:399:43:399:47 | def | map.cpp:399:7:399:9 | ref arg m27 | TAINT |
18791873
| map.cpp:399:43:399:47 | def | map.cpp:399:11:399:21 | call to try_emplace | TAINT |
@@ -1884,8 +1878,6 @@
18841878
| map.cpp:401:23:401:25 | ref arg m27 | map.cpp:401:7:401:9 | m27 | |
18851879
| map.cpp:401:23:401:25 | ref arg m27 | map.cpp:402:7:402:9 | m27 | |
18861880
| map.cpp:401:23:401:25 | ref arg m27 | map.cpp:422:1:422:1 | m27 | |
1887-
| map.cpp:401:23:401:33 | call to iterator | map.cpp:401:7:401:9 | ref arg m27 | TAINT |
1888-
| map.cpp:401:23:401:33 | call to iterator | map.cpp:401:11:401:21 | call to try_emplace | TAINT |
18891881
| map.cpp:401:27:401:31 | call to begin | map.cpp:401:23:401:33 | call to iterator | TAINT |
18901882
| map.cpp:401:43:401:48 | call to source | map.cpp:401:7:401:9 | ref arg m27 | TAINT |
18911883
| map.cpp:401:43:401:48 | call to source | map.cpp:401:11:401:21 | call to try_emplace | TAINT |
@@ -1902,8 +1894,6 @@
19021894
| map.cpp:403:23:403:25 | ref arg m28 | map.cpp:405:23:405:25 | m28 | |
19031895
| map.cpp:403:23:403:25 | ref arg m28 | map.cpp:406:7:406:9 | m28 | |
19041896
| map.cpp:403:23:403:25 | ref arg m28 | map.cpp:422:1:422:1 | m28 | |
1905-
| map.cpp:403:23:403:33 | call to iterator | map.cpp:403:7:403:9 | ref arg m28 | TAINT |
1906-
| map.cpp:403:23:403:33 | call to iterator | map.cpp:403:11:403:21 | call to try_emplace | TAINT |
19071897
| map.cpp:403:27:403:31 | call to begin | map.cpp:403:23:403:33 | call to iterator | TAINT |
19081898
| map.cpp:403:43:403:47 | def | map.cpp:403:7:403:9 | ref arg m28 | TAINT |
19091899
| map.cpp:403:43:403:47 | def | map.cpp:403:11:403:21 | call to try_emplace | TAINT |
@@ -1914,8 +1904,6 @@
19141904
| map.cpp:405:23:405:25 | ref arg m28 | map.cpp:405:7:405:9 | m28 | |
19151905
| map.cpp:405:23:405:25 | ref arg m28 | map.cpp:406:7:406:9 | m28 | |
19161906
| map.cpp:405:23:405:25 | ref arg m28 | map.cpp:422:1:422:1 | m28 | |
1917-
| map.cpp:405:23:405:33 | call to iterator | map.cpp:405:7:405:9 | ref arg m28 | TAINT |
1918-
| map.cpp:405:23:405:33 | call to iterator | map.cpp:405:11:405:21 | call to try_emplace | TAINT |
19191907
| map.cpp:405:27:405:31 | call to begin | map.cpp:405:23:405:33 | call to iterator | TAINT |
19201908
| map.cpp:405:46:405:50 | def | map.cpp:405:7:405:9 | ref arg m28 | TAINT |
19211909
| map.cpp:405:46:405:50 | def | map.cpp:405:11:405:21 | call to try_emplace | TAINT |

0 commit comments

Comments
 (0)