Skip to content

Commit 609d812

Browse files
committed
fix alias edge bug
1 parent a5e8baf commit 609d812

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

src/main/java/tabby/core/container/DataContainer.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,31 @@ public MethodReference getFirstMethodRefFromFatherNodes(SootClass cls, String su
317317
return null;
318318
}
319319

320+
public Set<MethodReference> getAliasMethodRefs(SootClass cls, String subSignature){
321+
Set<MethodReference> refs = new HashSet<>();
322+
Set<SootClass> classes = new HashSet<>();
323+
324+
if(cls.hasSuperclass()){
325+
classes.add(cls.getSuperclass());
326+
}
327+
328+
if(cls.getInterfaceCount() > 0){
329+
classes.addAll(cls.getInterfaces());
330+
}
331+
332+
MethodReference ref = null;
333+
334+
for(SootClass clazz:classes){
335+
ref = getMethodRefBySubSignature(clazz.getName(), subSignature);
336+
if(ref != null){
337+
refs.add(ref);
338+
}else{
339+
refs.addAll(getAliasMethodRefs(clazz, subSignature));
340+
}
341+
}
342+
return refs;
343+
}
344+
320345
private MethodReference getTargetMethodRef(SootClass cls, String subSignature, boolean deepFirst){
321346
MethodReference target = null;
322347
if(deepFirst){

src/main/java/tabby/core/scanner/ClassInfoScanner.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,17 @@ public static void makeAliasRelation(Has has, DataContainer dataContainer){
198198
if(currentSootMethod == null) return;
199199

200200
SootClass cls = currentSootMethod.getDeclaringClass();
201-
MethodReference fatherNodeMethodRef
202-
= dataContainer.getFirstMethodRefFromFatherNodes(
203-
cls, currentSootMethod.getSubSignature(), false);
204201

205-
if(fatherNodeMethodRef != null){
206-
Alias alias = Alias.newInstance(fatherNodeMethodRef, currentMethodRef);
207-
fatherNodeMethodRef.getChildAliasEdges().add(alias);
202+
Set<MethodReference> refs =
203+
dataContainer.getAliasMethodRefs(cls, currentSootMethod.getSubSignature());
204+
205+
if(refs != null && !refs.isEmpty()){
206+
for(MethodReference ref:refs){
207+
Alias alias = Alias.newInstance(ref, currentMethodRef);
208+
ref.getChildAliasEdges().add(alias);
208209
// currentMethodRef.setAliasEdge(alias);
209-
dataContainer.store(alias);
210+
dataContainer.store(alias);
211+
}
210212
}
211213
}
212214

0 commit comments

Comments
 (0)