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 {
4949 }
5050
5151 /**
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).
5354 */
5455 int getAStringParameter ( ) {
5556 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`
5759 }
5860
5961 override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
Original file line number Diff line number Diff line change 579579| stl.cpp:366:3:366:4 | ref arg s9 | stl.cpp:367:8:367:9 | s9 | |
580580| stl.cpp:366:13:366:15 | | stl.cpp:366:3:366:4 | ref arg s9 | TAINT |
581581| 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 |
582589| structlikeclass.cpp:5:7:5:7 | Unknown literal | structlikeclass.cpp:5:7:5:7 | constructor init of field v | TAINT |
583590| structlikeclass.cpp:5:7:5:7 | Unknown literal | structlikeclass.cpp:5:7:5:7 | constructor init of field v | TAINT |
584591| 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() {
372372 char c = ns_char::source ();
373373
374374 s10.append (1 , c);
375- sink (s10); // tainted [NOT DETECTED]
375+ sink (s10); // tainted
376376 }
377377}
Original file line number Diff line number Diff line change 6262| stl.cpp:358:8:358:9 | s7 | stl.cpp:356:9:356:14 | call to source |
6363| stl.cpp:362:8:362:9 | s8 | stl.cpp:345:18:345:23 | call to source |
6464| 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 |
6566| structlikeclass.cpp:35:8:35:9 | s1 | structlikeclass.cpp:29:22:29:27 | call to source |
6667| structlikeclass.cpp:36:8:36:9 | s2 | structlikeclass.cpp:30:24:30:29 | call to source |
6768| 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 5959| stl.cpp:358:8:358:9 | stl.cpp:356:9:356:14 | AST only |
6060| stl.cpp:362:8:362:9 | stl.cpp:345:18:345:23 | AST only |
6161| 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 |
6263| structlikeclass.cpp:35:8:35:9 | structlikeclass.cpp:29:22:29:27 | AST only |
6364| structlikeclass.cpp:36:8:36:9 | structlikeclass.cpp:30:24:30:29 | AST only |
6465| 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