File tree Expand file tree Collapse file tree 5 files changed +46
-0
lines changed
cpp/ql/test/library-tests/dataflow/taint-tests Expand file tree Collapse file tree 5 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 188
188
| stl.cpp:131:15:131:24 | call to user_input | stl.cpp:131:15:131:27 | call to basic_string | TAINT |
189
189
| stl.cpp:131:15:131:27 | call to basic_string | stl.cpp:132:7:132:11 | path3 | |
190
190
| stl.cpp:132:7:132:11 | path3 | stl.cpp:132:13:132:17 | call to c_str | TAINT |
191
+ | stl.cpp:137:19:137:24 | call to source | stl.cpp:140:17:140:18 | cs | |
192
+ | stl.cpp:137:19:137:24 | call to source | stl.cpp:142:7:142:8 | cs | |
193
+ | stl.cpp:140:17:140:18 | cs | stl.cpp:140:17:140:19 | call to basic_string | TAINT |
194
+ | stl.cpp:140:17:140:19 | call to basic_string | stl.cpp:143:7:143:8 | ss | |
195
+ | stl.cpp:148:19:148:24 | call to source | stl.cpp:151:17:151:18 | cs | |
196
+ | stl.cpp:151:17:151:18 | cs | stl.cpp:151:17:151:19 | call to basic_string | TAINT |
197
+ | stl.cpp:151:17:151:19 | call to basic_string | stl.cpp:154:7:154:8 | ss | |
198
+ | stl.cpp:151:17:151:19 | call to basic_string | stl.cpp:157:7:157:8 | ss | |
199
+ | stl.cpp:154:7:154:8 | ss | stl.cpp:154:10:154:14 | call to c_str | TAINT |
200
+ | stl.cpp:154:10:154:14 | call to c_str | stl.cpp:154:2:154:16 | ... = ... | |
201
+ | stl.cpp:154:10:154:14 | call to c_str | stl.cpp:156:7:156:8 | cs | |
191
202
| taint.cpp:4:27:4:33 | source1 | taint.cpp:6:13:6:19 | source1 | |
192
203
| taint.cpp:4:40:4:45 | clean1 | taint.cpp:5:8:5:13 | clean1 | |
193
204
| taint.cpp:4:40:4:45 | clean1 | taint.cpp:6:3:6:8 | clean1 | |
Original file line number Diff line number Diff line change @@ -131,3 +131,28 @@ void test_strings2()
131
131
string path3 (user_input ());
132
132
sink (path3.c_str (), " r" ); // tainted
133
133
}
134
+
135
+ void test_string3 ()
136
+ {
137
+ const char *cs = source ();
138
+
139
+ // convert char * -> std::string
140
+ std::string ss (cs);
141
+
142
+ sink (cs); // tainted
143
+ sink (ss); // tainted
144
+ }
145
+
146
+ void test_string4 ()
147
+ {
148
+ const char *cs = source ();
149
+
150
+ // convert char * -> std::string
151
+ std::string ss (cs);
152
+
153
+ // convert back std::string -> char *
154
+ cs = ss.c_str ();
155
+
156
+ sink (cs); // tainted
157
+ sink (ss); // tainted
158
+ }
Original file line number Diff line number Diff line change 16
16
| stl.cpp:125:13:125:17 | call to c_str | stl.cpp:117:10:117:15 | call to source |
17
17
| stl.cpp:129:13:129:17 | call to c_str | stl.cpp:117:10:117:15 | call to source |
18
18
| stl.cpp:132:13:132:17 | call to c_str | stl.cpp:117:10:117:15 | call to source |
19
+ | stl.cpp:142:7:142:8 | cs | stl.cpp:137:19:137:24 | call to source |
20
+ | stl.cpp:143:7:143:8 | ss | stl.cpp:137:19:137:24 | call to source |
21
+ | stl.cpp:156:7:156:8 | cs | stl.cpp:148:19:148:24 | call to source |
22
+ | stl.cpp:157:7:157:8 | ss | stl.cpp:148:19:148:24 | call to source |
19
23
| taint.cpp:8:8:8:13 | clean1 | taint.cpp:4:27:4:33 | source1 |
20
24
| taint.cpp:16:8:16:14 | source1 | taint.cpp:12:22:12:27 | call to source |
21
25
| taint.cpp:17:8:17:16 | ++ ... | taint.cpp:12:22:12:27 | call to source |
Original file line number Diff line number Diff line change 13
13
| stl.cpp:125:13:125:17 | stl.cpp:117:10:117:15 | AST only |
14
14
| stl.cpp:129:13:129:17 | stl.cpp:117:10:117:15 | AST only |
15
15
| stl.cpp:132:13:132:17 | stl.cpp:117:10:117:15 | AST only |
16
+ | stl.cpp:142:7:142:8 | stl.cpp:137:19:137:26 | IR only |
17
+ | stl.cpp:143:7:143:8 | stl.cpp:137:19:137:24 | AST only |
18
+ | stl.cpp:156:7:156:8 | stl.cpp:148:19:148:24 | AST only |
19
+ | stl.cpp:157:7:157:8 | stl.cpp:148:19:148:24 | AST only |
16
20
| taint.cpp:41:7:41:13 | taint.cpp:35:12:35:17 | AST only |
17
21
| taint.cpp:42:7:42:13 | taint.cpp:35:12:35:17 | AST only |
18
22
| taint.cpp:43:7:43:13 | taint.cpp:37:22:37:27 | AST only |
Original file line number Diff line number Diff line change 3
3
| format.cpp:158:7:158:27 | ... + ... | format.cpp:148:16:148:30 | call to source |
4
4
| stl.cpp:71:7:71:7 | (const char *)... | stl.cpp:67:12:67:17 | call to source |
5
5
| stl.cpp:71:7:71:7 | a | stl.cpp:67:12:67:17 | call to source |
6
+ | stl.cpp:142:7:142:8 | cs | stl.cpp:137:19:137:24 | call to source |
7
+ | stl.cpp:142:7:142:8 | cs | stl.cpp:137:19:137:26 | (const char *)... |
6
8
| taint.cpp:8:8:8:13 | clean1 | taint.cpp:4:27:4:33 | source1 |
7
9
| taint.cpp:16:8:16:14 | source1 | taint.cpp:12:22:12:27 | call to source |
8
10
| taint.cpp:17:8:17:16 | ++ ... | taint.cpp:12:22:12:27 | call to source |
You can’t perform that action at this time.
0 commit comments