mirror of
https://github.com/revanced/Apktool.git
synced 2024-11-19 19:09:24 +01:00
Add some additional checks related to instruction size
This commit is contained in:
parent
fe42130f05
commit
959133cbf0
@ -41,6 +41,7 @@ import org.jf.dexlib2.iface.MethodImplementation;
|
||||
import org.jf.dexlib2.iface.debug.DebugItem;
|
||||
import org.jf.dexlib2.iface.instruction.Instruction;
|
||||
import org.jf.util.AlignmentUtils;
|
||||
import org.jf.util.ExceptionWithContext;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -77,7 +78,15 @@ public class DexBackedMethodImplementation implements MethodImplementation {
|
||||
if (reader.getOffset() >= endOffset) {
|
||||
return null;
|
||||
}
|
||||
return DexBackedInstruction.readFrom(reader);
|
||||
|
||||
Instruction instruction = DexBackedInstruction.readFrom(reader);
|
||||
|
||||
// Does the instruction extend past the end of the method?
|
||||
int offset = reader.getOffset();
|
||||
if (offset > endOffset || offset < 0) {
|
||||
throw new ExceptionWithContext("The last instruction in the method is truncated");
|
||||
}
|
||||
return instruction;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -56,6 +56,9 @@ public class DexBackedArrayPayload extends DexBackedInstruction implements Array
|
||||
|
||||
elementWidth = dexFile.readUshort(instructionStart + ELEMENT_WIDTH_OFFSET);
|
||||
elementCount = dexFile.readSmallUint(instructionStart + ELEMENT_COUNT_OFFSET);
|
||||
if (((long)elementWidth) * elementCount > Integer.MAX_VALUE) {
|
||||
throw new ExceptionWithContext("Invalid array-payload instruction: element width*count overflows");
|
||||
}
|
||||
}
|
||||
|
||||
@Override public int getElementWidth() { return elementWidth; }
|
||||
|
Loading…
Reference in New Issue
Block a user