@@ -167,11 +167,15 @@ private class IteratorAssignArithmeticOperator extends Operator, DataFlowFunctio
167167 override predicate hasDataFlow ( FunctionInput input , FunctionOutput output ) {
168168 input .isParameter ( 0 ) and
169169 output .isReturnValue ( )
170- or
171- input .isParameterDeref ( 0 ) and output .isReturnValueDeref ( )
172170 }
173171
174172 override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
173+ input .isParameterDeref ( 0 ) and output .isReturnValueDeref ( )
174+ or
175+ // reverse flow from returned reference to the object referenced by the first parameter
176+ input .isReturnValueDeref ( ) and
177+ output .isParameterDeref ( 0 )
178+ or
175179 input .isParameterDeref ( 1 ) and
176180 output .isParameterDeref ( 0 )
177181 }
@@ -224,9 +228,7 @@ private class IteratorCrementMemberOperator extends MemberFunction, DataFlowFunc
224228 * A member `operator->` function for an iterator type.
225229 */
226230private class IteratorFieldMemberOperator extends Operator , TaintFunction {
227- IteratorFieldMemberOperator ( ) {
228- this .getClassAndName ( "operator->" ) instanceof Iterator
229- }
231+ IteratorFieldMemberOperator ( ) { this .getClassAndName ( "operator->" ) instanceof Iterator }
230232
231233 override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
232234 input .isQualifierObject ( ) and
@@ -260,14 +262,18 @@ private class IteratorAssignArithmeticMemberOperator extends MemberFunction, Dat
260262 override predicate hasDataFlow ( FunctionInput input , FunctionOutput output ) {
261263 input .isQualifierAddress ( ) and
262264 output .isReturnValue ( )
263- or
264- input .isReturnValueDeref ( ) and
265- output .isQualifierObject ( )
266265 }
267266
268267 override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
269268 input .isQualifierObject ( ) and
270269 output .isReturnValueDeref ( )
270+ or
271+ // reverse flow from returned reference to the qualifier
272+ input .isReturnValueDeref ( ) and
273+ output .isQualifierObject ( )
274+ or
275+ input .isParameterDeref ( 0 ) and
276+ output .isQualifierObject ( )
271277 }
272278}
273279
@@ -276,9 +282,7 @@ private class IteratorAssignArithmeticMemberOperator extends MemberFunction, Dat
276282 */
277283private class IteratorArrayMemberOperator extends MemberFunction , TaintFunction ,
278284 IteratorReferenceFunction {
279- IteratorArrayMemberOperator ( ) {
280- this .getClassAndName ( "operator[]" ) instanceof Iterator
281- }
285+ IteratorArrayMemberOperator ( ) { this .getClassAndName ( "operator[]" ) instanceof Iterator }
282286
283287 override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
284288 input .isQualifierObject ( ) and
0 commit comments