@@ -120,21 +120,6 @@ private Set<Abstraction> computeAliases(final DefinitionStmt defStmt, Value left
120120
121121 final Set <Abstraction > res = new MutableTwoElementSet <Abstraction >();
122122
123- // Check whether the left side of the assignment matches our
124- // current taint abstraction
125- final boolean leftSideMatches = Aliasing .baseMatches (leftValue , source );
126- if (!leftSideMatches )
127- res .add (source );
128- else {
129- // The left side is overwritten completely
130-
131- // If we have an assignment to the base local of the current
132- // taint, all taint propagations must be below that point,
133- // so this is the right point to turn around.
134- for (Unit u : interproceduralCFG ().getPredsOf (defStmt ))
135- manager .getMainSolver ().processEdge (new PathEdge <Unit , Abstraction >(d1 , u , source ));
136- }
137-
138123 // We only handle assignments and identity statements
139124 if (defStmt instanceof IdentityStmt ) {
140125 res .add (source );
@@ -143,6 +128,12 @@ private Set<Abstraction> computeAliases(final DefinitionStmt defStmt, Value left
143128 if (!(defStmt instanceof AssignStmt ))
144129 return res ;
145130
131+ // Check whether the left side of the assignment matches our
132+ // current taint abstraction
133+ final boolean leftSideMatches = Aliasing .baseMatches (leftValue , source );
134+ if (!leftSideMatches )
135+ res .add (source );
136+
146137 // Get the right side of the assignment
147138 final Value rightValue = BaseSelector .selectBase (defStmt .getRightOp (), false );
148139
@@ -240,21 +231,12 @@ else if (defStmt.getRightOp() instanceof LengthExpr) {
240231 newLeftAbs = checkAbstraction (source .deriveNewAbstraction (ap , defStmt ));
241232 }
242233
243- if (newLeftAbs != null ) {
244- // If we ran into a new abstraction that points to a
245- // primitive value, we can remove it
246- if (newLeftAbs .getAccessPath ().getLastFieldType () instanceof PrimType )
247- return res ;
248-
249- if (!newLeftAbs .getAccessPath ().equals (source .getAccessPath ())) {
250- // Propagate the new alias upwards
251- res .add (newLeftAbs );
252-
253- // Inject the new alias into the forward solver
254- for (Unit u : interproceduralCFG ().getPredsOf (defStmt ))
255- manager .getMainSolver ()
256- .processEdge (new PathEdge <Unit , Abstraction >(d1 , u , newLeftAbs ));
257- }
234+ if (newLeftAbs != null && !newLeftAbs .getAccessPath ().equals (source .getAccessPath ())) {
235+ // Only inject the new alias into the forward solver but never propagate it upwards
236+ // because the alias was created at this program point and won't be valid above.
237+ for (Unit u : interproceduralCFG ().getPredsOf (defStmt ))
238+ manager .getMainSolver ()
239+ .processEdge (new PathEdge <Unit , Abstraction >(d1 , u , newLeftAbs ));
258240 }
259241 }
260242
@@ -734,6 +716,42 @@ public Set<Abstraction> computeTargets(Abstraction source, Abstraction d1,
734716 if (abs != null ) {
735717 res .add (abs );
736718 registerActivationCallSite (callSite , callee , abs );
719+
720+ // Check whether the call site created an alias by having two equal
721+ // arguments, e.g. caller(o, o);. If yes, inject the other parameter
722+ // back into the callee.
723+ for (int argIndex = 0 ; !isReflectiveCallSite && argIndex < ie .getArgCount (); argIndex ++) {
724+ if (i != argIndex && originalCallArg == ie .getArg (argIndex )) {
725+ AccessPath aliasAp = manager .getAccessPathFactory ().copyWithNewValue (
726+ source .getAccessPath (), paramLocals [argIndex ],
727+ source .getAccessPath ().getBaseType (),
728+ false );
729+ Abstraction aliasAbs = checkAbstraction (
730+ source .deriveNewAbstraction (aliasAp , (Stmt ) exitStmt ));
731+
732+ manager .getMainSolver ()
733+ .processEdge (new PathEdge <>(d1 , exitStmt , aliasAbs ));
734+ }
735+ }
736+
737+ // A foo(A a) {
738+ // return a;
739+ // }
740+ // A b = foo(a);
741+ // An alias is created using the returned value. If no assignment
742+ // happen inside the method, also no handover is triggered. Thus,
743+ // for this special case, we hand over the current taint and let the
744+ // forward analysis find out whether the return value actually created
745+ // an alias or not.
746+ for (Unit u : manager .getICFG ().getStartPointsOf (callee )) {
747+ if (!(u instanceof ReturnStmt ))
748+ continue ;
749+
750+ if (paramLocals [i ] == ((ReturnStmt ) u ).getOp ()) {
751+ manager .getMainSolver ().processEdge (new PathEdge <>(d1 , exitStmt , source ));
752+ break ;
753+ }
754+ }
737755 }
738756 }
739757 }
0 commit comments