@@ -92,6 +92,9 @@ class IteratorPointerDereferenceOperator extends Operator, TaintFunction, Iterat
9292 override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
9393 input = iteratorInput and
9494 output .isReturnValue ( )
95+ or
96+ input .isReturnValueDeref ( ) and
97+ output .isParameterDeref ( 0 )
9598 }
9699}
97100
@@ -180,6 +183,9 @@ class IteratorPointerDereferenceMemberOperator extends MemberFunction, TaintFunc
180183 override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
181184 input .isQualifierObject ( ) and
182185 output .isReturnValue ( )
186+ or
187+ input .isReturnValueDeref ( ) and
188+ output .isQualifierObject ( )
183189 }
184190}
185191
@@ -274,11 +280,32 @@ class IteratorArrayMemberOperator extends MemberFunction, TaintFunction, Iterato
274280 }
275281}
276282
283+ /**
284+ * An `operator=` member function of an iterator class that is not a copy or move assignment
285+ * operator.
286+ *
287+ * The `hasTaintFlow` override provides flow through output iterators that return themselves with
288+ * `operator*` and use their own `operator=` to assign to the container.
289+ */
290+ class IteratorAssignmentMemberOperator extends MemberFunction , TaintFunction {
291+ IteratorAssignmentMemberOperator ( ) {
292+ this .hasName ( "operator=" ) and
293+ this .getDeclaringType ( ) instanceof Iterator and
294+ not this instanceof CopyAssignmentOperator and
295+ not this instanceof MoveAssignmentOperator
296+ }
297+
298+ override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
299+ input .isParameterDeref ( 0 ) and
300+ output .isQualifierObject ( )
301+ }
302+ }
303+
277304/**
278305 * A `begin` or `end` member function, or a related member function, that
279306 * returns an iterator.
280307 */
281- class BeginOrEndFunction extends MemberFunction , TaintFunction {
308+ class BeginOrEndFunction extends MemberFunction , TaintFunction , GetIteratorFunction {
282309 BeginOrEndFunction ( ) {
283310 this
284311 .hasName ( [ "begin" , "cbegin" , "rbegin" , "crbegin" , "end" , "cend" , "rend" , "crend" ,
@@ -290,4 +317,24 @@ class BeginOrEndFunction extends MemberFunction, TaintFunction {
290317 input .isQualifierObject ( ) and
291318 output .isReturnValue ( )
292319 }
320+
321+ override predicate getsIterator ( FunctionInput input , FunctionOutput output ) {
322+ input .isQualifierObject ( ) and
323+ output .isReturnValue ( )
324+ }
325+ }
326+
327+ /**
328+ * The `std::front_inserter`, `std::inserter`, and `std::back_inserter`
329+ * functions.
330+ */
331+ class InserterIteratorFunction extends GetIteratorFunction {
332+ InserterIteratorFunction ( ) {
333+ this .hasQualifiedName ( "std" , [ "front_inserter" , "inserter" , "back_inserter" ] )
334+ }
335+
336+ override predicate getsIterator ( FunctionInput input , FunctionOutput output ) {
337+ input .isParameterDeref ( 0 ) and
338+ output .isReturnValue ( )
339+ }
293340}
0 commit comments