fix: check if debug info offset is invalid (#1653)
This commit is contained in:
@@ -21,6 +21,7 @@ import jadx.core.dex.visitors.JadxVisitor;
|
||||
import jadx.core.dex.visitors.blocks.BlockSplitter;
|
||||
import jadx.core.dex.visitors.ssa.SSATransform;
|
||||
import jadx.core.utils.ListUtils;
|
||||
import jadx.core.utils.exceptions.InvalidDataException;
|
||||
import jadx.core.utils.exceptions.JadxException;
|
||||
|
||||
@JadxVisitor(
|
||||
@@ -40,6 +41,8 @@ public class DebugInfoAttachVisitor extends AbstractVisitor {
|
||||
if (debugInfo != null) {
|
||||
processDebugInfo(mth, debugInfo);
|
||||
}
|
||||
} catch (InvalidDataException e) {
|
||||
mth.addWarnComment(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
mth.addWarnComment("Failed to parse debug info", e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package jadx.core.utils.exceptions;
|
||||
|
||||
public class InvalidDataException extends JadxRuntimeException {
|
||||
public InvalidDataException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
+4
@@ -16,6 +16,7 @@ import jadx.api.plugins.input.data.ITry;
|
||||
import jadx.api.plugins.input.data.impl.CatchData;
|
||||
import jadx.api.plugins.input.data.impl.TryData;
|
||||
import jadx.api.plugins.input.insns.InsnData;
|
||||
import jadx.core.utils.exceptions.InvalidDataException;
|
||||
import jadx.plugins.input.dex.DexException;
|
||||
import jadx.plugins.input.dex.insns.DexInsnData;
|
||||
import jadx.plugins.input.dex.insns.DexInsnFormat;
|
||||
@@ -112,6 +113,9 @@ public class DexCodeReader implements ICodeReader {
|
||||
if (debugOff == 0) {
|
||||
return null;
|
||||
}
|
||||
if (debugOff < 0 || debugOff > in.size()) {
|
||||
throw new InvalidDataException("Invalid debug info offset");
|
||||
}
|
||||
int regsCount = getRegistersCount();
|
||||
DebugInfoParser debugInfoParser = new DebugInfoParser(in, regsCount, getUnitsCount());
|
||||
debugInfoParser.initMthArgs(regsCount, in.getMethodParamTypes(mthId));
|
||||
|
||||
+4
@@ -314,6 +314,10 @@ public class SectionReader {
|
||||
return Leb128.readSignedLeb128(this);
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return buf.capacity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SectionReader{buf=" + buf + ", offset=" + offset + '}';
|
||||
|
||||
Reference in New Issue
Block a user