mirror of
https://github.com/revanced/smali.git
synced 2025-05-29 04:10:13 +02:00
Add some additional checks related to instruction size
This commit is contained in:
parent
20d4a3c2b4
commit
686cf35c8e
@ -41,6 +41,7 @@ import org.jf.dexlib2.iface.MethodImplementation;
|
|||||||
import org.jf.dexlib2.iface.debug.DebugItem;
|
import org.jf.dexlib2.iface.debug.DebugItem;
|
||||||
import org.jf.dexlib2.iface.instruction.Instruction;
|
import org.jf.dexlib2.iface.instruction.Instruction;
|
||||||
import org.jf.util.AlignmentUtils;
|
import org.jf.util.AlignmentUtils;
|
||||||
|
import org.jf.util.ExceptionWithContext;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -77,7 +78,15 @@ public class DexBackedMethodImplementation implements MethodImplementation {
|
|||||||
if (reader.getOffset() >= endOffset) {
|
if (reader.getOffset() >= endOffset) {
|
||||||
return null;
|
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);
|
elementWidth = dexFile.readUshort(instructionStart + ELEMENT_WIDTH_OFFSET);
|
||||||
elementCount = dexFile.readSmallUint(instructionStart + ELEMENT_COUNT_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; }
|
@Override public int getElementWidth() { return elementWidth; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user