@@ -164,7 +164,9 @@ private class IteratorCrementNonMemberOperatorModel extends IteratorCrementNonMe
164164 input = getIteratorArgumentInput ( this , 0 ) and
165165 output .isReturnValue ( )
166166 or
167- input .isParameterDeref ( 0 ) and output .isReturnValueDeref ( )
167+ exists ( int indirectionIndex |
168+ input .isParameterDeref ( 0 , indirectionIndex ) and output .isReturnValueDeref ( indirectionIndex )
169+ )
168170 }
169171
170172 override predicate hasOnlySpecificReadSideEffects ( ) { any ( ) }
@@ -205,16 +207,21 @@ private class IteratorCrementMemberOperatorModel extends IteratorCrementMemberOp
205207 input .isQualifierAddress ( ) and
206208 output .isReturnValue ( )
207209 or
208- input .isReturnValueDeref ( ) and
209- output .isQualifierObject ( )
210- or
211- input .isQualifierObject ( ) and
212- output .isReturnValueDeref ( )
210+ exists ( int indirectionIndex |
211+ // reverse flow
212+ input .isReturnValueDeref ( indirectionIndex ) and
213+ output .isQualifierObject ( indirectionIndex )
214+ or
215+ input .isQualifierObject ( indirectionIndex ) and
216+ output .isReturnValueDeref ( indirectionIndex )
217+ )
213218 }
214219
215220 override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
216- input .isQualifierObject ( ) and
217- output .isReturnValueDeref ( )
221+ exists ( int indirectionIndex |
222+ input .isQualifierObject ( indirectionIndex ) and
223+ output .isReturnValueDeref ( indirectionIndex )
224+ )
218225 }
219226
220227 override predicate hasOnlySpecificReadSideEffects ( ) { any ( ) }
@@ -286,8 +293,11 @@ private class IteratorBinaryArithmeticMemberOperatorModel extends IteratorBinary
286293 TaintFunction
287294{
288295 override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
289- input .isQualifierObject ( ) and
290- output .isReturnValue ( )
296+ exists ( int indirectionIndex | input .isQualifierObject ( indirectionIndex ) |
297+ output .isReturnValueDeref ( indirectionIndex )
298+ or
299+ output .isReturnValue ( )
300+ )
291301 }
292302}
293303
@@ -346,15 +356,23 @@ private class IteratorAssignArithmeticNonMemberOperatorModel extends IteratorAss
346356 }
347357
348358 override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
349- input .isParameterDeref ( 0 ) and output .isReturnValueDeref ( )
350- or
351- // reverse flow from returned reference to the object referenced by the first parameter
352- input .isReturnValueDeref ( ) and
353- output .isParameterDeref ( 0 )
354- or
355- ( input .isParameter ( 1 ) or input .isParameterDeref ( 1 ) ) and
356- output .isParameterDeref ( 0 )
359+ exists ( int indirectionIndex |
360+ input .isParameterDeref ( 0 , indirectionIndex ) and output .isReturnValueDeref ( indirectionIndex )
361+ or
362+ // reverse flow from returned reference to the object referenced by the first parameter
363+ input .isReturnValueDeref ( indirectionIndex ) and
364+ output .isParameterDeref ( 0 , indirectionIndex )
365+ or
366+ (
367+ input .isParameter ( 1 ) and indirectionIndex = 0
368+ or
369+ input .isParameterDeref ( 1 , indirectionIndex )
370+ ) and
371+ output .isParameterDeref ( 0 , indirectionIndex + 1 )
372+ )
357373 }
374+
375+ override predicate isPartialWrite ( FunctionOutput output ) { output .isParameterDeref ( 0 , _) }
358376}
359377
360378/**
@@ -378,16 +396,25 @@ private class IteratorAssignArithmeticMemberOperatorModel extends IteratorAssign
378396 }
379397
380398 override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
381- input .isQualifierObject ( ) and
382- output .isReturnValueDeref ( )
383- or
384- // reverse flow from returned reference to the qualifier
385- input .isReturnValueDeref ( ) and
386- output .isQualifierObject ( )
387- or
388- ( input .isParameter ( 0 ) or input .isParameterDeref ( 0 ) ) and
389- output .isQualifierObject ( )
399+ exists ( int indirectionIndex |
400+ input .isParameterDeref ( 0 , indirectionIndex ) and output .isReturnValueDeref ( indirectionIndex )
401+ or
402+ input .isQualifierObject ( indirectionIndex ) and output .isReturnValueDeref ( indirectionIndex )
403+ or
404+ // reverse flow from returned reference to the object referenced by the first parameter
405+ input .isReturnValueDeref ( indirectionIndex ) and
406+ output .isQualifierObject ( indirectionIndex )
407+ or
408+ (
409+ input .isParameter ( 0 ) and indirectionIndex = 0
410+ or
411+ input .isParameterDeref ( 0 , indirectionIndex )
412+ ) and
413+ output .isQualifierObject ( indirectionIndex + 1 )
414+ )
390415 }
416+
417+ override predicate isPartialWrite ( FunctionOutput output ) { output .isQualifierObject ( _) }
391418}
392419
393420/**
@@ -414,11 +441,14 @@ class IteratorPointerDereferenceMemberOperator extends MemberFunction, TaintFunc
414441 }
415442
416443 override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
417- input .isQualifierObject ( ) and
418- output .isReturnValue ( )
419- or
420- input .isReturnValueDeref ( ) and
421- output .isQualifierObject ( )
444+ exists ( int indirectionIndex |
445+ input .isQualifierObject ( indirectionIndex ) and
446+ ( output .isReturnValueDeref ( indirectionIndex ) or output .isReturnValue ( ) )
447+ or
448+ // reverse flow
449+ input .isReturnValueDeref ( indirectionIndex ) and
450+ output .isQualifierObject ( indirectionIndex )
451+ )
422452 }
423453
424454 override predicate parameterNeverEscapes ( int index ) { index = - 1 }
@@ -454,8 +484,10 @@ private class IteratorPointerDereferenceNonMemberOperatorModel extends IteratorP
454484 input = getIteratorArgumentInput ( this , 0 ) and
455485 output .isReturnValue ( )
456486 or
457- input .isReturnValueDeref ( ) and
458- output .isParameterDeref ( 0 )
487+ exists ( int indirectionIndex |
488+ input .isReturnValueDeref ( indirectionIndex ) and
489+ output .isParameterDeref ( 0 , indirectionIndex )
490+ )
459491 }
460492
461493 override predicate parameterNeverEscapes ( int index ) { index = 0 }
@@ -488,8 +520,10 @@ private class IteratorFieldMemberOperator extends Operator, TaintFunction {
488520 IteratorFieldMemberOperator ( ) { this .getClassAndName ( "operator->" ) instanceof Iterator }
489521
490522 override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
491- input .isQualifierObject ( ) and
492- output .isReturnValue ( )
523+ exists ( int indirectionIndex |
524+ input .isQualifierObject ( indirectionIndex ) and
525+ output .isReturnValueDeref ( indirectionIndex ) // TODO
526+ )
493527 }
494528}
495529
@@ -502,8 +536,10 @@ private class IteratorArrayMemberOperator extends MemberFunction, TaintFunction,
502536 IteratorArrayMemberOperator ( ) { this .getClassAndName ( "operator[]" ) instanceof Iterator }
503537
504538 override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
505- input .isQualifierObject ( ) and
506- output .isReturnValue ( )
539+ exists ( int indirectionIndex |
540+ input .isQualifierObject ( indirectionIndex ) and
541+ output .isReturnValueDeref ( indirectionIndex ) // TODO
542+ )
507543 }
508544}
509545
@@ -595,8 +631,11 @@ private class IteratorAssignmentMemberOperatorModel extends IteratorAssignmentMe
595631 TaintFunction , SideEffectFunction , AliasFunction
596632{
597633 override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
598- ( input .isParameterDeref ( 0 ) or input .isParameter ( 0 ) ) and
599- output .isQualifierObject ( )
634+ exists ( int indirectionIndex | output .isQualifierObject ( indirectionIndex + 1 ) |
635+ input .isParameterDeref ( 0 , indirectionIndex )
636+ or
637+ input .isParameter ( 0 ) and indirectionIndex = 0
638+ )
600639 }
601640
602641 override predicate hasOnlySpecificReadSideEffects ( ) { any ( ) }
@@ -669,8 +708,11 @@ private class BeginOrEndFunctionModels extends BeginOrEndFunction, TaintFunction
669708 GetIteratorFunction , AliasFunction , SideEffectFunction
670709{
671710 override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
672- input .isQualifierObject ( ) and
673- output .isReturnValue ( )
711+ exists ( int indirectionIndex | input .isQualifierObject ( indirectionIndex ) |
712+ // output.isReturnValue()
713+ // or
714+ output .isReturnValueDeref ( indirectionIndex ) // TODO
715+ )
674716 }
675717
676718 override predicate getsIterator ( FunctionInput input , FunctionOutput output ) {
0 commit comments