mirror of
https://github.com/revanced/smali.git
synced 2025-06-13 04:27:38 +02:00
Implemented verification for aput-object
git-svn-id: https://smali.googlecode.com/svn/trunk@592 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
@ -526,6 +526,8 @@ public class MethodAnalyzer {
|
|||||||
return handle32BitPrimitiveAput(analyzedInstruction, RegisterType.Category.Short);
|
return handle32BitPrimitiveAput(analyzedInstruction, RegisterType.Category.Short);
|
||||||
case APUT_WIDE:
|
case APUT_WIDE:
|
||||||
return handleAputWide(analyzedInstruction);
|
return handleAputWide(analyzedInstruction);
|
||||||
|
case APUT_OBJECT:
|
||||||
|
return handleAputObject(analyzedInstruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert false;
|
assert false;
|
||||||
@ -1644,6 +1646,56 @@ public class MethodAnalyzer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean handleAputObject(AnalyzedInstruction analyzedInstruction) {
|
||||||
|
ThreeRegisterInstruction instruction = (ThreeRegisterInstruction)analyzedInstruction.instruction;
|
||||||
|
|
||||||
|
RegisterType indexRegisterType = analyzedInstruction.getPreInstructionRegisterType(instruction.getRegisterC());
|
||||||
|
assert indexRegisterType != null;
|
||||||
|
if (indexRegisterType.category == RegisterType.Category.Unknown) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
checkRegister(indexRegisterType, Primitive32BitCategories);
|
||||||
|
|
||||||
|
RegisterType sourceRegisterType = analyzedInstruction.getPreInstructionRegisterType(instruction.getRegisterA());
|
||||||
|
assert sourceRegisterType != null;
|
||||||
|
if (sourceRegisterType.category == RegisterType.Category.Unknown) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
RegisterType arrayRegisterType = analyzedInstruction.getPreInstructionRegisterType(instruction.getRegisterB());
|
||||||
|
assert arrayRegisterType != null;
|
||||||
|
if (indexRegisterType.category == RegisterType.Category.Unknown) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arrayRegisterType.category != RegisterType.Category.Null) {
|
||||||
|
//don't check the source type against the array type, just make sure it is an array of reference types
|
||||||
|
|
||||||
|
if (arrayRegisterType.category != RegisterType.Category.Reference) {
|
||||||
|
throw new ValidationException(String.format("Cannot use aget-object with non-array type %s",
|
||||||
|
arrayRegisterType.category.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
assert arrayRegisterType.type != null;
|
||||||
|
if (arrayRegisterType.type.getClassType().charAt(0) != '[') {
|
||||||
|
throw new ValidationException(String.format("Cannot use aget-object with non-array type %s",
|
||||||
|
arrayRegisterType.type.getClassType()));
|
||||||
|
}
|
||||||
|
|
||||||
|
assert arrayRegisterType.type instanceof ClassPath.ArrayClassDef;
|
||||||
|
ClassPath.ArrayClassDef arrayClassDef = (ClassPath.ArrayClassDef)arrayRegisterType.type;
|
||||||
|
|
||||||
|
ClassPath.ClassDef elementClassDef = arrayClassDef.getImmediateElementClass();
|
||||||
|
char elementTypePrefix = elementClassDef.getClassType().charAt(0);
|
||||||
|
if (elementTypePrefix != 'L' && elementTypePrefix != '[') {
|
||||||
|
throw new ValidationException(String.format("Cannot use aget-object with array type %s. Incorrect " +
|
||||||
|
"array type for the instruction.", arrayRegisterType.type.getClassType()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
Reference in New Issue
Block a user