Skip to content

Commit 0663c9e

Browse files
authored
Merge pull request #557 from timll/parameterMismatch
Notes on argument/parameter mismatch
2 parents 6a4bbb0 + 9e88932 commit 0663c9e

2 files changed

Lines changed: 18 additions & 11 deletions

File tree

soot-infoflow/src/soot/jimple/infoflow/problems/BackwardsInfoflowProblem.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,8 @@ private Set<Abstraction> computeTargetsInternal(Abstraction d1, Abstraction sour
570570
if (abs != null)
571571
res.add(abs);
572572
}
573-
} else if (ie != null && dest.getParameterCount() > 0) {
573+
} else if (ie != null && dest.getParameterCount() > 0
574+
&& (isReflectiveCallSite || ie.getArgCount() == dest.getParameterCount())) {
574575
for (int i = isReflectiveCallSite ? 1 : 0; i < ie.getArgCount(); i++) {
575576
if (!aliasing.mayAlias(ie.getArg(i), source.getAccessPath().getPlainValue()))
576577
continue;
@@ -588,17 +589,18 @@ private Set<Abstraction> computeTargetsInternal(Abstraction d1, Abstraction sour
588589
if (interproceduralCFG().methodWritesValue(dest, paramLocals[i]))
589590
continue;
590591

591-
// taint all parameters if reflective call site
592592
if (isReflectiveCallSite) {
593+
// taint all parameters if the arg array of an reflective
594+
// call site is tainted
593595
for (Value param : paramLocals) {
594596
AccessPath ap = manager.getAccessPathFactory()
595597
.copyWithNewValue(source.getAccessPath(), param, null, false);
596598
Abstraction abs = source.deriveNewAbstraction(ap, stmt);
597599
if (abs != null)
598600
res.add(abs);
599601
}
600-
// taint just the tainted parameter
601602
} else {
603+
// taint just the tainted parameter
602604
AccessPath ap = manager.getAccessPathFactory()
603605
.copyWithNewValue(source.getAccessPath(), paramLocals[i]);
604606
Abstraction abs = source.deriveNewAbstraction(ap, stmt);
@@ -609,6 +611,12 @@ private Set<Abstraction> computeTargetsInternal(Abstraction d1, Abstraction sour
609611
}
610612
}
611613

614+
// Sometimes callers have more arguments than the callee parameters, e.g.
615+
// because one argument is resolved in native code. A concrete example is
616+
// sendMessageDelayed(android.os.Message, int)
617+
// -> handleMessage(android.os.Message message)
618+
// TODO: handle argument/parameter mismatch for some special cases
619+
612620
return res;
613621
}
614622
};

soot-infoflow/src/soot/jimple/infoflow/problems/InfoflowProblem.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,14 +1007,7 @@ private Set<AccessPath> mapAccessPathToCallee(final SootMethod callee, final Inv
10071007
if (newAP != null)
10081008
res.add(newAP);
10091009
}
1010-
} else if (i < paramLocals.length) {
1011-
// Sometimes callers have more arguments than the callee parameters. For
1012-
// example, this is the case on a call from
1013-
// sendMessageDelayed(android.os.Message, int)
1014-
// to the callee handler handleMessage(android.os.Message message). The delay is
1015-
// handled native and not present in the call-graph. In this case, we just break
1016-
// out of the loop as no more params are left to be mapped into the callee
1017-
1010+
} else {
10181011
// Taint the corresponding parameter local in the callee
10191012
AccessPath newAP = manager.getAccessPathFactory().copyWithNewValue(ap,
10201013
paramLocals[i]);
@@ -1024,6 +1017,12 @@ private Set<AccessPath> mapAccessPathToCallee(final SootMethod callee, final Inv
10241017
}
10251018
}
10261019
}
1020+
1021+
// Sometimes callers have more arguments than the callee parameters, e.g.
1022+
// because one argument is resolved in native code. A concrete example is
1023+
// sendMessageDelayed(android.os.Message, int)
1024+
// -> handleMessage(android.os.Message message)
1025+
// TODO: handle argument/parameter mismatch for some special cases
10271026
}
10281027
return res;
10291028
}

0 commit comments

Comments
 (0)