File tree Expand file tree Collapse file tree 6 files changed +39
-1
lines changed
src/semmle/code/cpp/models
test/library-tests/dataflow/taint-tests Expand file tree Collapse file tree 6 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -12,4 +12,5 @@ private import implementations.Strcat
12
12
private import implementations.Strcpy
13
13
private import implementations.Strdup
14
14
private import implementations.Strftime
15
+ private import implementations.Strings
15
16
private import implementations.Swap
Original file line number Diff line number Diff line change
1
+ import semmle.code.cpp.models.interfaces.DataFlow
2
+ import semmle.code.cpp.models.interfaces.Taint
3
+
4
+ /**
5
+ * The `std::basic_string` constructor(s).
6
+ */
7
+ class StringConstructor extends DataFlowFunction {
8
+ StringConstructor ( ) {
9
+ this .hasQualifiedName ( "std" , "basic_string" , "basic_string" )
10
+ }
11
+
12
+ override predicate hasDataFlow ( FunctionInput input , FunctionOutput output ) {
13
+ // flow from any constructor argument to return value
14
+ input .isInParameter ( _) and
15
+ output .isOutReturnValue ( )
16
+ }
17
+ }
18
+
19
+ /**
20
+ * The standard function `std::string.c_str`.
21
+ */
22
+ class StringCStr extends DataFlowFunction {
23
+ StringCStr ( ) {
24
+ this .hasQualifiedName ( "std" , "basic_string" , "c_str" )
25
+ }
26
+
27
+ override predicate hasDataFlow ( FunctionInput input , FunctionOutput output ) {
28
+ // flow from string itself (qualifier) to return value
29
+ input .isInQualifier ( ) and
30
+ output .isOutReturnValue ( )
31
+ }
32
+ }
Original file line number Diff line number Diff line change 106
106
| format.cpp:131:39:131:45 | ref arg & ... | format.cpp:132:8:132:13 | buffer | |
107
107
| format.cpp:131:40:131:45 | buffer | format.cpp:131:39:131:45 | & ... | |
108
108
| stl.cpp:67:12:67:17 | call to source | stl.cpp:71:7:71:7 | a | |
109
+ | stl.cpp:68:16:68:20 | 123 | stl.cpp:68:16:68:21 | call to basic_string | |
109
110
| stl.cpp:68:16:68:21 | call to basic_string | stl.cpp:72:7:72:7 | b | |
110
111
| stl.cpp:68:16:68:21 | call to basic_string | stl.cpp:74:7:74:7 | b | |
112
+ | stl.cpp:69:16:69:21 | call to source | stl.cpp:69:16:69:24 | call to basic_string | |
111
113
| stl.cpp:69:16:69:24 | call to basic_string | stl.cpp:73:7:73:7 | c | |
112
114
| stl.cpp:69:16:69:24 | call to basic_string | stl.cpp:75:7:75:7 | c | |
113
115
| stl.cpp:80:20:80:22 | call to basic_stringstream | stl.cpp:83:2:83:4 | ss1 | |
125
127
| stl.cpp:80:40:80:42 | call to basic_stringstream | stl.cpp:87:2:87:4 | ss5 | |
126
128
| stl.cpp:80:40:80:42 | call to basic_stringstream | stl.cpp:93:7:93:9 | ss5 | |
127
129
| stl.cpp:80:40:80:42 | call to basic_stringstream | stl.cpp:98:7:98:9 | ss5 | |
130
+ | stl.cpp:81:16:81:21 | call to source | stl.cpp:81:16:81:24 | call to basic_string | |
128
131
| stl.cpp:81:16:81:24 | call to basic_string | stl.cpp:87:9:87:9 | t | |
129
132
| stl.cpp:83:2:83:4 | ref arg ss1 | stl.cpp:89:7:89:9 | ss1 | |
130
133
| stl.cpp:83:2:83:4 | ref arg ss1 | stl.cpp:94:7:94:9 | ss1 | |
Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ void test_string()
70
70
71
71
sink (a); // tainted
72
72
sink (b);
73
- sink (c); // tainted [NOT DETECTED]
73
+ sink (c); // tainted
74
74
sink (b.c_str ());
75
75
sink (c.c_str ()); // tainted [NOT DETECTED]
76
76
}
Original file line number Diff line number Diff line change 9
9
| format.cpp:101:8:101:13 | buffer | format.cpp:100:31:100:45 | call to source |
10
10
| format.cpp:106:8:106:14 | wbuffer | format.cpp:105:38:105:52 | call to source |
11
11
| stl.cpp:71:7:71:7 | a | stl.cpp:67:12:67:17 | call to source |
12
+ | stl.cpp:73:7:73:7 | c | stl.cpp:69:16:69:21 | call to source |
12
13
| taint.cpp:8:8:8:13 | clean1 | taint.cpp:4:27:4:33 | source1 |
13
14
| taint.cpp:16:8:16:14 | source1 | taint.cpp:12:22:12:27 | call to source |
14
15
| 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 8
8
| format.cpp:96:8:96:13 | format.cpp:95:30:95:43 | AST only |
9
9
| format.cpp:101:8:101:13 | format.cpp:100:31:100:45 | AST only |
10
10
| format.cpp:106:8:106:14 | format.cpp:105:38:105:52 | AST only |
11
+ | stl.cpp:73:7:73:7 | stl.cpp:69:16:69:21 | AST only |
11
12
| taint.cpp:41:7:41:13 | taint.cpp:35:12:35:17 | AST only |
12
13
| taint.cpp:42:7:42:13 | taint.cpp:35:12:35:17 | AST only |
13
14
| taint.cpp:43:7:43:13 | taint.cpp:37:22:37:27 | AST only |
You can’t perform that action at this time.
0 commit comments