File tree Expand file tree Collapse file tree 5 files changed +17
-4
lines changed
src/semmle/code/cpp/models/implementations
test/library-tests/dataflow/taint-tests Expand file tree Collapse file tree 5 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -40,10 +40,13 @@ class StdStringPlus extends TaintFunction {
40
40
}
41
41
42
42
/**
43
- * The `std::string` function `append`.
43
+ * The `std::string` functions `operator+=` and `append`.
44
44
*/
45
45
class StdStringAppend extends TaintFunction {
46
- StdStringAppend ( ) { this .hasQualifiedName ( "std" , "basic_string" , "append" ) }
46
+ StdStringAppend ( ) {
47
+ this .hasQualifiedName ( "std" , "basic_string" , "operator+=" ) or
48
+ this .hasQualifiedName ( "std" , "basic_string" , "append" )
49
+ }
47
50
48
51
override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
49
52
// flow from parameter to string itself (qualifier) and return value
Original file line number Diff line number Diff line change 549
549
| stl.cpp:342:8:342:9 | s3 | stl.cpp:343:3:343:4 | s6 | |
550
550
| stl.cpp:342:8:342:9 | s3 | stl.cpp:344:8:344:9 | s6 | |
551
551
| stl.cpp:343:3:343:4 | ref arg s6 | stl.cpp:344:8:344:9 | s6 | |
552
+ | stl.cpp:343:9:343:10 | s4 | stl.cpp:343:3:343:4 | ref arg s6 | TAINT |
553
+ | stl.cpp:343:9:343:10 | s4 | stl.cpp:343:6:343:6 | call to operator+= | TAINT |
552
554
| stl.cpp:346:8:346:9 | s3 | stl.cpp:346:3:346:9 | ... = ... | |
553
555
| stl.cpp:346:8:346:9 | s3 | stl.cpp:347:3:347:4 | s7 | |
554
556
| stl.cpp:346:8:346:9 | s3 | stl.cpp:348:3:348:4 | s7 | |
555
557
| stl.cpp:346:8:346:9 | s3 | stl.cpp:349:8:349:9 | s7 | |
556
558
| stl.cpp:347:3:347:4 | ref arg s7 | stl.cpp:348:3:348:4 | s7 | |
557
559
| stl.cpp:347:3:347:4 | ref arg s7 | stl.cpp:349:8:349:9 | s7 | |
560
+ | stl.cpp:347:9:347:14 | call to source | stl.cpp:347:3:347:4 | ref arg s7 | TAINT |
561
+ | stl.cpp:347:9:347:14 | call to source | stl.cpp:347:6:347:6 | call to operator+= | TAINT |
558
562
| stl.cpp:348:3:348:4 | ref arg s7 | stl.cpp:349:8:349:9 | s7 | |
563
+ | stl.cpp:348:9:348:11 | | stl.cpp:348:3:348:4 | ref arg s7 | TAINT |
564
+ | stl.cpp:348:9:348:11 | | stl.cpp:348:6:348:6 | call to operator+= | TAINT |
559
565
| stl.cpp:351:8:351:9 | s3 | stl.cpp:351:3:351:9 | ... = ... | |
560
566
| stl.cpp:351:8:351:9 | s3 | stl.cpp:352:3:352:4 | s8 | |
561
567
| stl.cpp:351:8:351:9 | s3 | stl.cpp:353:8:353:9 | s8 | |
Original file line number Diff line number Diff line change @@ -341,12 +341,12 @@ void test_string_append() {
341
341
342
342
s6 = s3;
343
343
s6 += s4;
344
- sink (s6); // tainted [NOT DETECTED]
344
+ sink (s6); // tainted
345
345
346
346
s7 = s3;
347
347
s7 += source ();
348
348
s7 += " " ;
349
- sink (s7); // tainted [NOT DETECTED]
349
+ sink (s7); // tainted
350
350
351
351
s8 = s3;
352
352
s8.append (s4);
Original file line number Diff line number Diff line change 58
58
| stl.cpp:328:11:328:11 | call to operator+ | stl.cpp:323:18:323:23 | call to source |
59
59
| stl.cpp:331:11:331:11 | call to operator+ | stl.cpp:331:13:331:18 | call to source |
60
60
| stl.cpp:340:8:340:9 | s5 | stl.cpp:336:18:336:23 | call to source |
61
+ | stl.cpp:344:8:344:9 | s6 | stl.cpp:336:18:336:23 | call to source |
62
+ | stl.cpp:349:8:349:9 | s7 | stl.cpp:347:9:347:14 | call to source |
61
63
| stl.cpp:353:8:353:9 | s8 | stl.cpp:336:18:336:23 | call to source |
62
64
| stl.cpp:358:8:358:9 | s9 | stl.cpp:356:13:356:18 | call to source |
63
65
| structlikeclass.cpp:35:8:35:9 | s1 | structlikeclass.cpp:29:22:29:27 | call to source |
Original file line number Diff line number Diff line change 55
55
| stl.cpp:328:11:328:11 | stl.cpp:323:18:323:23 | AST only |
56
56
| stl.cpp:331:11:331:11 | stl.cpp:331:13:331:18 | AST only |
57
57
| stl.cpp:340:8:340:9 | stl.cpp:336:18:336:23 | AST only |
58
+ | stl.cpp:344:8:344:9 | stl.cpp:336:18:336:23 | AST only |
59
+ | stl.cpp:349:8:349:9 | stl.cpp:347:9:347:14 | AST only |
58
60
| stl.cpp:353:8:353:9 | stl.cpp:336:18:336:23 | AST only |
59
61
| stl.cpp:358:8:358:9 | stl.cpp:356:13:356:18 | AST only |
60
62
| structlikeclass.cpp:35:8:35:9 | structlikeclass.cpp:29:22:29:27 | AST only |
You can’t perform that action at this time.
0 commit comments