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

Skip to content

Commit 983f54f

Browse files
author
Robert Marsh
committed
C++: simple tests for vector output iterators
1 parent 9879c6c commit 983f54f

2 files changed

Lines changed: 109 additions & 0 deletions

File tree

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

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3173,3 +3173,85 @@
31733173
| vector.cpp:324:7:324:8 | ref arg v2 | vector.cpp:327:1:327:1 | v2 | |
31743174
| vector.cpp:325:7:325:8 | ref arg v3 | vector.cpp:327:1:327:1 | v3 | |
31753175
| vector.cpp:326:7:326:8 | ref arg v4 | vector.cpp:327:1:327:1 | v4 | |
3176+
| vector.cpp:329:62:329:65 | iter | vector.cpp:330:3:330:6 | iter | |
3177+
| vector.cpp:330:2:330:17 | ... = ... | vector.cpp:330:2:330:2 | call to operator* [post update] | |
3178+
| vector.cpp:330:3:330:6 | iter | vector.cpp:330:2:330:2 | call to operator* | TAINT |
3179+
| vector.cpp:330:10:330:15 | call to source | vector.cpp:330:2:330:17 | ... = ... | |
3180+
| vector.cpp:334:22:334:24 | call to vector | vector.cpp:336:34:336:35 | v1 | |
3181+
| vector.cpp:334:22:334:24 | call to vector | vector.cpp:338:7:338:8 | v1 | |
3182+
| vector.cpp:334:22:334:24 | call to vector | vector.cpp:354:1:354:1 | v1 | |
3183+
| vector.cpp:334:30:334:32 | call to vector | vector.cpp:340:38:340:39 | v2 | |
3184+
| vector.cpp:334:30:334:32 | call to vector | vector.cpp:340:56:340:57 | v2 | |
3185+
| vector.cpp:334:30:334:32 | call to vector | vector.cpp:343:7:343:8 | v2 | |
3186+
| vector.cpp:334:30:334:32 | call to vector | vector.cpp:354:1:354:1 | v2 | |
3187+
| vector.cpp:334:38:334:40 | call to vector | vector.cpp:345:15:345:16 | v3 | |
3188+
| vector.cpp:334:38:334:40 | call to vector | vector.cpp:348:7:348:8 | v3 | |
3189+
| vector.cpp:334:38:334:40 | call to vector | vector.cpp:354:1:354:1 | v3 | |
3190+
| vector.cpp:334:46:334:48 | call to vector | vector.cpp:350:38:350:39 | v4 | |
3191+
| vector.cpp:334:46:334:48 | call to vector | vector.cpp:350:56:350:57 | v4 | |
3192+
| vector.cpp:334:46:334:48 | call to vector | vector.cpp:353:7:353:8 | v4 | |
3193+
| vector.cpp:334:46:334:48 | call to vector | vector.cpp:354:1:354:1 | v4 | |
3194+
| vector.cpp:336:34:336:35 | ref arg v1 | vector.cpp:338:7:338:8 | v1 | |
3195+
| vector.cpp:336:34:336:35 | ref arg v1 | vector.cpp:354:1:354:1 | v1 | |
3196+
| vector.cpp:336:34:336:35 | v1 | vector.cpp:336:37:336:41 | call to begin | TAINT |
3197+
| vector.cpp:336:37:336:41 | call to begin | vector.cpp:337:3:337:4 | i1 | |
3198+
| vector.cpp:337:2:337:15 | ... = ... | vector.cpp:337:2:337:2 | call to operator* [post update] | |
3199+
| vector.cpp:337:3:337:4 | i1 | vector.cpp:337:2:337:2 | call to operator* | TAINT |
3200+
| vector.cpp:337:8:337:13 | call to source | vector.cpp:337:2:337:15 | ... = ... | |
3201+
| vector.cpp:338:7:338:8 | ref arg v1 | vector.cpp:354:1:354:1 | v1 | |
3202+
| vector.cpp:340:38:340:39 | ref arg v2 | vector.cpp:340:56:340:57 | v2 | |
3203+
| vector.cpp:340:38:340:39 | ref arg v2 | vector.cpp:343:7:343:8 | v2 | |
3204+
| vector.cpp:340:38:340:39 | ref arg v2 | vector.cpp:354:1:354:1 | v2 | |
3205+
| vector.cpp:340:38:340:39 | v2 | vector.cpp:340:41:340:45 | call to begin | TAINT |
3206+
| vector.cpp:340:41:340:45 | call to begin | vector.cpp:340:50:340:51 | it | |
3207+
| vector.cpp:340:41:340:45 | call to begin | vector.cpp:340:68:340:69 | it | |
3208+
| vector.cpp:340:41:340:45 | call to begin | vector.cpp:341:4:341:5 | it | |
3209+
| vector.cpp:340:56:340:57 | ref arg v2 | vector.cpp:340:56:340:57 | v2 | |
3210+
| vector.cpp:340:56:340:57 | ref arg v2 | vector.cpp:343:7:343:8 | v2 | |
3211+
| vector.cpp:340:56:340:57 | ref arg v2 | vector.cpp:354:1:354:1 | v2 | |
3212+
| vector.cpp:340:56:340:57 | v2 | vector.cpp:340:59:340:61 | call to end | TAINT |
3213+
| vector.cpp:340:68:340:69 | it | vector.cpp:340:66:340:66 | call to operator++ | TAINT |
3214+
| vector.cpp:340:68:340:69 | ref arg it | vector.cpp:340:50:340:51 | it | |
3215+
| vector.cpp:340:68:340:69 | ref arg it | vector.cpp:340:68:340:69 | it | |
3216+
| vector.cpp:340:68:340:69 | ref arg it | vector.cpp:341:4:341:5 | it | |
3217+
| vector.cpp:341:3:341:16 | ... = ... | vector.cpp:341:3:341:3 | call to operator* [post update] | |
3218+
| vector.cpp:341:4:341:5 | it | vector.cpp:341:3:341:3 | call to operator* | TAINT |
3219+
| vector.cpp:341:9:341:14 | call to source | vector.cpp:341:3:341:16 | ... = ... | |
3220+
| vector.cpp:343:7:343:8 | ref arg v2 | vector.cpp:354:1:354:1 | v2 | |
3221+
| vector.cpp:345:15:345:15 | (__begin) | vector.cpp:345:15:345:15 | call to operator* | TAINT |
3222+
| vector.cpp:345:15:345:15 | (__begin) | vector.cpp:345:15:345:15 | call to operator++ | TAINT |
3223+
| vector.cpp:345:15:345:15 | (__end) | vector.cpp:345:15:345:15 | call to iterator | |
3224+
| vector.cpp:345:15:345:15 | (__range) | vector.cpp:345:15:345:15 | call to begin | TAINT |
3225+
| vector.cpp:345:15:345:15 | (__range) | vector.cpp:345:15:345:15 | call to end | TAINT |
3226+
| vector.cpp:345:15:345:15 | call to begin | vector.cpp:345:15:345:15 | (__begin) | |
3227+
| vector.cpp:345:15:345:15 | call to begin | vector.cpp:345:15:345:15 | (__begin) | |
3228+
| vector.cpp:345:15:345:15 | call to begin | vector.cpp:345:15:345:15 | (__begin) | |
3229+
| vector.cpp:345:15:345:15 | call to end | vector.cpp:345:15:345:15 | (__end) | |
3230+
| vector.cpp:345:15:345:15 | ref arg (__begin) | vector.cpp:345:15:345:15 | (__begin) | |
3231+
| vector.cpp:345:15:345:15 | ref arg (__begin) | vector.cpp:345:15:345:15 | (__begin) | |
3232+
| vector.cpp:345:15:345:15 | ref arg (__begin) | vector.cpp:345:15:345:15 | (__begin) | |
3233+
| vector.cpp:345:15:345:15 | ref arg (__range) | vector.cpp:345:15:345:15 | (__range) | |
3234+
| vector.cpp:345:15:345:16 | v3 | vector.cpp:345:15:345:15 | (__range) | |
3235+
| vector.cpp:345:15:345:16 | v3 | vector.cpp:345:15:345:15 | (__range) | |
3236+
| vector.cpp:345:15:345:16 | v3 | vector.cpp:345:15:345:15 | call to operator* | TAINT |
3237+
| vector.cpp:346:7:346:12 | call to source | vector.cpp:346:3:346:14 | ... = ... | |
3238+
| vector.cpp:348:7:348:8 | ref arg v3 | vector.cpp:354:1:354:1 | v3 | |
3239+
| vector.cpp:350:38:350:39 | ref arg v4 | vector.cpp:350:56:350:57 | v4 | |
3240+
| vector.cpp:350:38:350:39 | ref arg v4 | vector.cpp:353:7:353:8 | v4 | |
3241+
| vector.cpp:350:38:350:39 | ref arg v4 | vector.cpp:354:1:354:1 | v4 | |
3242+
| vector.cpp:350:38:350:39 | v4 | vector.cpp:350:41:350:45 | call to begin | TAINT |
3243+
| vector.cpp:350:41:350:45 | call to begin | vector.cpp:350:50:350:51 | it | |
3244+
| vector.cpp:350:41:350:45 | call to begin | vector.cpp:350:68:350:69 | it | |
3245+
| vector.cpp:350:41:350:45 | call to begin | vector.cpp:351:4:351:5 | it | |
3246+
| vector.cpp:350:56:350:57 | ref arg v4 | vector.cpp:350:56:350:57 | v4 | |
3247+
| vector.cpp:350:56:350:57 | ref arg v4 | vector.cpp:353:7:353:8 | v4 | |
3248+
| vector.cpp:350:56:350:57 | ref arg v4 | vector.cpp:354:1:354:1 | v4 | |
3249+
| vector.cpp:350:56:350:57 | v4 | vector.cpp:350:59:350:61 | call to end | TAINT |
3250+
| vector.cpp:350:68:350:69 | it | vector.cpp:350:66:350:66 | call to operator++ | TAINT |
3251+
| vector.cpp:350:68:350:69 | ref arg it | vector.cpp:350:50:350:51 | it | |
3252+
| vector.cpp:350:68:350:69 | ref arg it | vector.cpp:350:68:350:69 | it | |
3253+
| vector.cpp:350:68:350:69 | ref arg it | vector.cpp:351:4:351:5 | it | |
3254+
| vector.cpp:351:3:351:16 | ... = ... | vector.cpp:351:3:351:3 | call to operator* [post update] | |
3255+
| vector.cpp:351:4:351:5 | it | vector.cpp:351:3:351:3 | call to operator* | TAINT |
3256+
| vector.cpp:351:9:351:14 | call to source | vector.cpp:351:3:351:16 | ... = ... | |
3257+
| vector.cpp:353:7:353:8 | ref arg v4 | vector.cpp:354:1:354:1 | v4 | |

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,3 +325,30 @@ void test_constructors_more() {
325325
sink(v3);
326326
sink(v4); // tainted
327327
}
328+
329+
void taint_vector_output_iterator(std::vector<int>::iterator iter) {
330+
*iter = source();
331+
}
332+
333+
void test_vector_output_iterator() {
334+
std::vector<int> v1(10), v2(10), v3(10), v4(10);
335+
336+
std::vector<int>::iterator i1 = v1.begin();
337+
*i1 = source();
338+
sink(v1); // tainted [NOT DETECTED]
339+
340+
for(std::vector<int>::iterator it = v2.begin(); it != v2.end(); ++it) {
341+
*it = source(); // tainted [NOT DETECTED]
342+
}
343+
sink(v2);
344+
345+
for(int& x : v3) {
346+
x = source();
347+
}
348+
sink(v3); // tainted [NOT DETECTED]
349+
350+
for(std::vector<int>::iterator it = v4.begin(); it != v4.end(); ++it) {
351+
*it = source();
352+
}
353+
sink(v4); // tainted [NOT DETECTED]
354+
}

0 commit comments

Comments
 (0)