File tree Expand file tree Collapse file tree 5 files changed +14
-3
lines changed
src/semmle/code/cpp/models/implementations
test/library-tests/dataflow/taint-tests Expand file tree Collapse file tree 5 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -49,11 +49,13 @@ class StdStringAppend extends TaintFunction {
49
49
}
50
50
51
51
/**
52
- * Gets the index of a parameter to this function that is a string.
52
+ * Gets the index of a parameter to this function that is a string (or
53
+ * character).
53
54
*/
54
55
int getAStringParameter ( ) {
55
56
getParameter ( result ) .getType ( ) instanceof PointerType or
56
- getParameter ( result ) .getType ( ) instanceof ReferenceType
57
+ getParameter ( result ) .getType ( ) instanceof ReferenceType or
58
+ getParameter ( result ) .getType ( ) = getDeclaringType ( ) .getTemplateArgument ( 0 ) // i.e. `std::basic_string::CharT`
57
59
}
58
60
59
61
override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
Original file line number Diff line number Diff line change 579
579
| stl.cpp:366:3:366:4 | ref arg s9 | stl.cpp:367:8:367:9 | s9 | |
580
580
| stl.cpp:366:13:366:15 | | stl.cpp:366:3:366:4 | ref arg s9 | TAINT |
581
581
| stl.cpp:366:13:366:15 | | stl.cpp:366:6:366:11 | call to append | TAINT |
582
+ | stl.cpp:371:19:371:23 | abc | stl.cpp:371:19:371:24 | call to basic_string | TAINT |
583
+ | stl.cpp:371:19:371:24 | call to basic_string | stl.cpp:374:3:374:5 | s10 | |
584
+ | stl.cpp:371:19:371:24 | call to basic_string | stl.cpp:375:8:375:10 | s10 | |
585
+ | stl.cpp:372:12:372:26 | call to source | stl.cpp:374:17:374:17 | c | |
586
+ | stl.cpp:374:3:374:5 | ref arg s10 | stl.cpp:375:8:375:10 | s10 | |
587
+ | stl.cpp:374:17:374:17 | c | stl.cpp:374:3:374:5 | ref arg s10 | TAINT |
588
+ | stl.cpp:374:17:374:17 | c | stl.cpp:374:7:374:12 | call to append | TAINT |
582
589
| structlikeclass.cpp:5:7:5:7 | Unknown literal | structlikeclass.cpp:5:7:5:7 | constructor init of field v | TAINT |
583
590
| structlikeclass.cpp:5:7:5:7 | Unknown literal | structlikeclass.cpp:5:7:5:7 | constructor init of field v | TAINT |
584
591
| structlikeclass.cpp:5:7:5:7 | this | structlikeclass.cpp:5:7:5:7 | constructor init of field v [pre-this] | |
Original file line number Diff line number Diff line change @@ -372,6 +372,6 @@ void test_string_append() {
372
372
char c = ns_char::source ();
373
373
374
374
s10.append (1 , c);
375
- sink (s10); // tainted [NOT DETECTED]
375
+ sink (s10); // tainted
376
376
}
377
377
}
Original file line number Diff line number Diff line change 62
62
| stl.cpp:358:8:358:9 | s7 | stl.cpp:356:9:356:14 | call to source |
63
63
| stl.cpp:362:8:362:9 | s8 | stl.cpp:345:18:345:23 | call to source |
64
64
| stl.cpp:367:8:367:9 | s9 | stl.cpp:365:13:365:18 | call to source |
65
+ | stl.cpp:375:8:375:10 | s10 | stl.cpp:372:12:372:26 | call to source |
65
66
| structlikeclass.cpp:35:8:35:9 | s1 | structlikeclass.cpp:29:22:29:27 | call to source |
66
67
| structlikeclass.cpp:36:8:36:9 | s2 | structlikeclass.cpp:30:24:30:29 | call to source |
67
68
| structlikeclass.cpp:37:8:37:9 | s3 | structlikeclass.cpp:29:22:29:27 | call to source |
Original file line number Diff line number Diff line change 59
59
| stl.cpp:358:8:358:9 | stl.cpp:356:9:356:14 | AST only |
60
60
| stl.cpp:362:8:362:9 | stl.cpp:345:18:345:23 | AST only |
61
61
| stl.cpp:367:8:367:9 | stl.cpp:365:13:365:18 | AST only |
62
+ | stl.cpp:375:8:375:10 | stl.cpp:372:12:372:26 | AST only |
62
63
| structlikeclass.cpp:35:8:35:9 | structlikeclass.cpp:29:22:29:27 | AST only |
63
64
| structlikeclass.cpp:36:8:36:9 | structlikeclass.cpp:30:24:30:29 | AST only |
64
65
| structlikeclass.cpp:37:8:37:9 | structlikeclass.cpp:29:22:29:27 | AST only |
You can’t perform that action at this time.
0 commit comments