Skip to content

Commit 5cd1daf

Browse files
committed
SummaryTaintWrapper: Cache propagator parent
1 parent cbe51d4 commit 5cd1daf

1 file changed

Lines changed: 42 additions & 18 deletions

File tree

soot-infoflow-summaries/src/soot/jimple/infoflow/methodSummary/taintWrappers/SummaryTaintWrapper.java

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ protected void handleFlowBackFromGap(Unit u, Abstraction d2, Set<AccessPathPropa
235235
for (AccessPathPropagator propagator : propagators) {
236236
// Propagate these taints up. We leave the current gap
237237
AccessPathPropagator parent = safePopParent(propagator);
238-
GapDefinition parentGap = propagator.getParent() == null ? null : propagator.getParent().getGap();
238+
final AccessPathPropagator pparent = propagator.getParent();
239+
GapDefinition parentGap = pparent == null ? null : pparent.getGap();
239240

240241
// Create taints from the abstractions
241242
Set<Taint> returnTaints = createTaintFromAccessPathOnReturn(d2.getAccessPath(), (Stmt) u,
@@ -250,10 +251,16 @@ protected void handleFlowBackFromGap(Unit u, Abstraction d2, Set<AccessPathPropa
250251
// Create the new propagator, one for every taint
251252
Set<AccessPathPropagator> workSet = new HashSet<>();
252253
for (Taint returnTaint : returnTaints) {
253-
AccessPathPropagator newPropagator = new AccessPathPropagator(returnTaint, parentGap, parent,
254-
propagator.getParent() == null ? null : propagator.getParent().getStmt(),
255-
propagator.getParent() == null ? null : propagator.getParent().getD1(),
256-
propagator.getParent() == null ? null : propagator.getParent().getD2());
254+
Stmt stmt = null;
255+
Abstraction d1 = null;
256+
Abstraction nd2 = null;
257+
if (pparent != null) {
258+
stmt = pparent.getStmt();
259+
d1 = pparent.getD1();
260+
nd2 = pparent.getD2();
261+
}
262+
AccessPathPropagator newPropagator = new AccessPathPropagator(returnTaint, parentGap, parent, stmt,
263+
d1, nd2);
257264
workSet.add(newPropagator);
258265
}
259266

@@ -335,9 +342,10 @@ private AccessPathPropagator getOriginalCallSite(AccessPathPropagator propagator
335342
// Get the original call site
336343
AccessPathPropagator curProp = propagator;
337344
while (curProp != null) {
338-
if (curProp.getParent() == null)
345+
final AccessPathPropagator parent = curProp.getParent();
346+
if (parent == null)
339347
return curProp;
340-
curProp = curProp.getParent();
348+
curProp = parent;
341349
}
342350
return null;
343351
}
@@ -1105,7 +1113,8 @@ protected Set<AccessPathPropagator> spawnAnalysisIntoClientCode(SootMethod imple
11051113

11061114
// We need to pop the last gap element off the stack
11071115
AccessPathPropagator parent = safePopParent(propagator);
1108-
GapDefinition gap = propagator.getParent() == null ? null : propagator.getParent().getGap();
1116+
AccessPathPropagator pparent = propagator.getParent();
1117+
GapDefinition gap = pparent == null ? null : pparent.getGap();
11091118

11101119
// We might already have a summary for the callee
11111120
Set<AccessPathPropagator> outgoingTaints = null;
@@ -1122,10 +1131,16 @@ protected Set<AccessPathPropagator> spawnAnalysisIntoClientCode(SootMethod imple
11221131
propagator.getGap());
11231132
if (newTaints != null) {
11241133
for (Taint newTaint : newTaints) {
1125-
AccessPathPropagator newPropagator = new AccessPathPropagator(newTaint, gap, parent,
1126-
propagator.getParent() == null ? null : propagator.getParent().getStmt(),
1127-
propagator.getParent() == null ? null : propagator.getParent().getD1(),
1128-
propagator.getParent() == null ? null : propagator.getParent().getD2());
1134+
Stmt nstmt = null;
1135+
Abstraction d1 = null;
1136+
Abstraction d2 = null;
1137+
if (pparent != null) {
1138+
nstmt = pparent.getStmt();
1139+
d1 = pparent.getD1();
1140+
d2 = pparent.getD2();
1141+
}
1142+
AccessPathPropagator newPropagator = new AccessPathPropagator(newTaint, gap, parent, nstmt,
1143+
d1, d2);
11291144
outgoingTaints.add(newPropagator);
11301145
}
11311146
}
@@ -1147,9 +1162,10 @@ protected Set<AccessPathPropagator> spawnAnalysisIntoClientCode(SootMethod imple
11471162
}
11481163

11491164
protected AccessPathPropagator safePopParent(AccessPathPropagator curPropagator) {
1150-
if (curPropagator.getParent() == null)
1165+
AccessPathPropagator parent = curPropagator.getParent();
1166+
if (parent == null)
11511167
return null;
1152-
return curPropagator.getParent().getParent();
1168+
return parent.getParent();
11531169
}
11541170

11551171
/**
@@ -1382,10 +1398,18 @@ protected AccessPathPropagator applyFlow(MethodFlow flow, AccessPathPropagator p
13821398
taintGap = null;
13831399
} else {
13841400
parent = safePopParent(propagator);
1385-
gap = propagator.getParent() == null ? null : propagator.getParent().getGap();
1386-
stmt = propagator.getParent() == null ? propagator.getStmt() : propagator.getParent().getStmt();
1387-
d1 = propagator.getParent() == null ? propagator.getD1() : propagator.getParent().getD1();
1388-
d2 = propagator.getParent() == null ? propagator.getD2() : propagator.getParent().getD2();
1401+
AccessPathPropagator pparent = propagator.getParent();
1402+
if (pparent == null) {
1403+
gap = null;
1404+
stmt = null;
1405+
d1 = null;
1406+
d2 = null;
1407+
} else {
1408+
gap = pparent.getGap();
1409+
stmt = pparent.getStmt();
1410+
d1 = pparent.getD1();
1411+
d2 = pparent.getD2();
1412+
}
13891413
taintGap = propagator.getGap();
13901414
}
13911415

0 commit comments

Comments
 (0)