fix: increase region iterative traversal limit (#767)
This commit is contained in:
@@ -6,10 +6,11 @@ import jadx.core.dex.nodes.IRegion;
|
||||
import jadx.core.dex.nodes.MethodNode;
|
||||
import jadx.core.dex.trycatch.ExceptionHandler;
|
||||
import jadx.core.utils.exceptions.JadxOverflowException;
|
||||
import jadx.core.utils.exceptions.JadxRuntimeException;
|
||||
|
||||
public class DepthRegionTraversal {
|
||||
|
||||
private static final int ITERATIVE_LIMIT = 500;
|
||||
private static final int ITERATIVE_LIMIT_MULTIPLIER = 5;
|
||||
|
||||
private DepthRegionTraversal() {
|
||||
}
|
||||
@@ -21,10 +22,13 @@ public class DepthRegionTraversal {
|
||||
public static void traverseIterative(MethodNode mth, IRegionIterativeVisitor visitor) {
|
||||
boolean repeat;
|
||||
int k = 0;
|
||||
int limit = ITERATIVE_LIMIT_MULTIPLIER * mth.getBasicBlocks().size();
|
||||
do {
|
||||
repeat = traverseIterativeStepInternal(mth, visitor, mth.getRegion());
|
||||
if (k++ > ITERATIVE_LIMIT) {
|
||||
throw new JadxOverflowException("Iterative traversal limit reached, method: " + mth);
|
||||
if (k++ > limit) {
|
||||
throw new JadxRuntimeException("Iterative traversal limit reached: "
|
||||
+ "limit: " + limit + ", visitor: " + visitor.getClass().getName()
|
||||
+ ", blocks count: " + mth.getBasicBlocks().size());
|
||||
}
|
||||
} while (repeat);
|
||||
}
|
||||
@@ -32,6 +36,7 @@ public class DepthRegionTraversal {
|
||||
public static void traverseIncludingExcHandlers(MethodNode mth, IRegionIterativeVisitor visitor) {
|
||||
boolean repeat;
|
||||
int k = 0;
|
||||
int limit = ITERATIVE_LIMIT_MULTIPLIER * mth.getBasicBlocks().size();
|
||||
do {
|
||||
repeat = traverseIterativeStepInternal(mth, visitor, mth.getRegion());
|
||||
if (!repeat) {
|
||||
@@ -42,8 +47,10 @@ public class DepthRegionTraversal {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (k++ > ITERATIVE_LIMIT) {
|
||||
throw new JadxOverflowException("Iterative traversal limit reached, method: " + mth);
|
||||
if (k++ > limit) {
|
||||
throw new JadxRuntimeException("Iterative traversal limit reached: "
|
||||
+ "limit: " + limit + ", visitor: " + visitor.getClass().getName()
|
||||
+ ", blocks count: " + mth.getBasicBlocks().size());
|
||||
}
|
||||
} while (repeat);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,10 @@ public class IfRegionVisitor extends AbstractVisitor {
|
||||
|
||||
@Override
|
||||
public void visit(MethodNode mth) {
|
||||
if (mth.isNoCode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
DepthRegionTraversal.traverseIterative(mth, TERNARY_VISITOR);
|
||||
DepthRegionTraversal.traverse(mth, PROCESS_IF_REGION_VISITOR);
|
||||
DepthRegionTraversal.traverseIterative(mth, REMOVE_REDUNDANT_ELSE_VISITOR);
|
||||
|
||||
Reference in New Issue
Block a user