mirror of
https://github.com/revanced/smali.git
synced 2025-05-09 19:04:32 +02:00
Implemented verification for iget-wide
git-svn-id: https://smali.googlecode.com/svn/trunk@594 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
parent
4f84e8f9e9
commit
9d92fd3748
@ -538,6 +538,8 @@ public class MethodAnalyzer {
|
|||||||
return handle32BitPrimitiveIget(analyzedInstruction, RegisterType.Category.Char);
|
return handle32BitPrimitiveIget(analyzedInstruction, RegisterType.Category.Char);
|
||||||
case IGET_SHORT:
|
case IGET_SHORT:
|
||||||
return handle32BitPrimitiveIget(analyzedInstruction, RegisterType.Category.Short);
|
return handle32BitPrimitiveIget(analyzedInstruction, RegisterType.Category.Short);
|
||||||
|
case IGET_WIDE:
|
||||||
|
return handleIgetWide(analyzedInstruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert false;
|
assert false;
|
||||||
@ -1743,6 +1745,45 @@ public class MethodAnalyzer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean handleIgetWide(AnalyzedInstruction analyzedInstruction) {
|
||||||
|
TwoRegisterInstruction instruction = (TwoRegisterInstruction)analyzedInstruction.instruction;
|
||||||
|
|
||||||
|
RegisterType objectRegisterType = analyzedInstruction.getPreInstructionRegisterType(instruction.getRegisterB());
|
||||||
|
assert objectRegisterType != null;
|
||||||
|
if (objectRegisterType.category == RegisterType.Category.Unknown) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
checkRegister(objectRegisterType, ReferenceCategories);
|
||||||
|
|
||||||
|
getAndCheckWideSourcePair(analyzedInstruction, instruction.getRegisterB());
|
||||||
|
|
||||||
|
//TODO: check access
|
||||||
|
//TODO: allow an uninitialized "this" reference, if the current method is an <init> method
|
||||||
|
Item referencedItem = ((InstructionWithReference)analyzedInstruction.instruction).getReferencedItem();
|
||||||
|
assert referencedItem instanceof FieldIdItem;
|
||||||
|
FieldIdItem field = (FieldIdItem)referencedItem;
|
||||||
|
|
||||||
|
if (objectRegisterType.category != RegisterType.Category.Null &&
|
||||||
|
!objectRegisterType.type.extendsClass(ClassPath.getClassDef(field.getContainingClass()))) {
|
||||||
|
throw new ValidationException(String.format("Cannot access field %s through type %s",
|
||||||
|
field.getFieldString(), objectRegisterType.type.getClassType()));
|
||||||
|
}
|
||||||
|
|
||||||
|
RegisterType fieldType = RegisterType.getRegisterTypeForTypeIdItem(field.getFieldType());
|
||||||
|
|
||||||
|
try {
|
||||||
|
checkRegister(fieldType, WideLowCategories);
|
||||||
|
} catch (ValidationException ex) {
|
||||||
|
throw new ValidationException(String.format("Cannot use %s with field %s. Incorrect field type " +
|
||||||
|
"for the instruction.", analyzedInstruction.instruction.opcode.name,
|
||||||
|
field.getFieldString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
setWideDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, fieldType);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean checkArrayFieldAssignment(RegisterType.Category arrayFieldCategory,
|
private static boolean checkArrayFieldAssignment(RegisterType.Category arrayFieldCategory,
|
||||||
RegisterType.Category instructionCategory) {
|
RegisterType.Category instructionCategory) {
|
||||||
if (arrayFieldCategory == instructionCategory) {
|
if (arrayFieldCategory == instructionCategory) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user