@@ -38,8 +38,7 @@ private class StdBasicStringIterator extends Iterator, Type {
38
38
*/
39
39
abstract private class StdStringTaintFunction extends TaintFunction {
40
40
/**
41
- * Gets the index of a parameter to this function that is a string (or
42
- * character).
41
+ * Gets the index of a parameter to this function that is a string.
43
42
*/
44
43
final int getAStringParameterIndex ( ) {
45
44
exists ( Type paramType | paramType = this .getParameter ( result ) .getUnspecifiedType ( ) |
@@ -50,7 +49,14 @@ abstract private class StdStringTaintFunction extends TaintFunction {
50
49
paramType instanceof ReferenceType and
51
50
not paramType .( ReferenceType ) .getBaseType ( ) =
52
51
this .getDeclaringType ( ) .getTemplateArgument ( 2 ) .( Type ) .getUnspecifiedType ( )
53
- or
52
+ )
53
+ }
54
+
55
+ /**
56
+ * Gets the index of a parameter to this function that is a character.
57
+ */
58
+ final int getACharParameterIndex ( ) {
59
+ exists ( Type paramType | paramType = this .getParameter ( result ) .getUnspecifiedType ( ) |
54
60
// i.e. `std::basic_string::CharT`
55
61
paramType = this .getDeclaringType ( ) .getTemplateArgument ( 0 ) .( Type ) .getUnspecifiedType ( )
56
62
)
@@ -79,6 +85,7 @@ private class StdStringConstructor extends Constructor, StdStringTaintFunction {
79
85
// taint flow from any parameter of the value type to the returned object
80
86
(
81
87
input .isParameterDeref ( this .getAStringParameterIndex ( ) ) or
88
+ input .isParameter ( this .getACharParameterIndex ( ) ) or
82
89
input .isParameter ( this .getAnIteratorParameterIndex ( ) )
83
90
) and
84
91
(
@@ -128,7 +135,7 @@ private class StdStringPush extends StdStringTaintFunction {
128
135
129
136
override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
130
137
// flow from parameter to qualifier
131
- input .isParameterDeref ( 0 ) and
138
+ input .isParameter ( 0 ) and
132
139
output .isQualifierObject ( )
133
140
}
134
141
}
@@ -180,6 +187,7 @@ private class StdStringAppend extends StdStringTaintFunction {
180
187
(
181
188
input .isQualifierObject ( ) or
182
189
input .isParameterDeref ( this .getAStringParameterIndex ( ) ) or
190
+ input .isParameter ( this .getACharParameterIndex ( ) ) or
183
191
input .isParameter ( this .getAnIteratorParameterIndex ( ) )
184
192
) and
185
193
(
@@ -210,6 +218,7 @@ private class StdStringInsert extends StdStringTaintFunction {
210
218
(
211
219
input .isQualifierObject ( ) or
212
220
input .isParameterDeref ( this .getAStringParameterIndex ( ) ) or
221
+ input .isParameter ( this .getACharParameterIndex ( ) ) or
213
222
input .isParameter ( this .getAnIteratorParameterIndex ( ) )
214
223
) and
215
224
(
@@ -236,6 +245,7 @@ private class StdStringAssign extends StdStringTaintFunction {
236
245
// flow from parameter to string itself (qualifier) and return value
237
246
(
238
247
input .isParameterDeref ( this .getAStringParameterIndex ( ) ) or
248
+ input .isParameter ( this .getACharParameterIndex ( ) ) or
239
249
input .isParameter ( this .getAnIteratorParameterIndex ( ) )
240
250
) and
241
251
(
0 commit comments