mirror of
https://github.com/revanced/smali.git
synced 2025-05-28 11:50:12 +02:00
Implemented verification for aput-wide
git-svn-id: https://smali.googlecode.com/svn/trunk@591 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
parent
c849236be2
commit
55d43e36eb
@ -524,6 +524,8 @@ public class MethodAnalyzer {
|
||||
return handle32BitPrimitiveAput(analyzedInstruction, RegisterType.Category.Char);
|
||||
case APUT_SHORT:
|
||||
return handle32BitPrimitiveAput(analyzedInstruction, RegisterType.Category.Short);
|
||||
case APUT_WIDE:
|
||||
return handleAputWide(analyzedInstruction);
|
||||
}
|
||||
|
||||
assert false;
|
||||
@ -1591,6 +1593,57 @@ public class MethodAnalyzer {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean handleAputWide(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 = getAndCheckWideSourcePair(analyzedInstruction, instruction.getRegisterA());
|
||||
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) {
|
||||
if (arrayRegisterType.category != RegisterType.Category.Reference) {
|
||||
throw new ValidationException(String.format("Cannot use aput-wide 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 aput-wide with non-array type %s",
|
||||
arrayRegisterType.type.getClassType()));
|
||||
}
|
||||
|
||||
assert arrayRegisterType.type instanceof ClassPath.ArrayClassDef;
|
||||
ClassPath.ArrayClassDef arrayClassDef = (ClassPath.ArrayClassDef)arrayRegisterType.type;
|
||||
|
||||
if (arrayClassDef.getArrayDimensions() != 1) {
|
||||
throw new ValidationException(String.format("Cannot use aput-wide with multi-dimensional array type %s",
|
||||
arrayRegisterType.type.getClassType()));
|
||||
}
|
||||
|
||||
char arrayBaseType = arrayClassDef.getBaseElementClass().getClassType().charAt(0);
|
||||
if (arrayBaseType != 'J' && arrayBaseType != 'D') {
|
||||
throw new ValidationException(String.format("Cannot use aput-wide with array type %s. Incorrect " +
|
||||
"array type for the instruction.", arrayRegisterType.type.getClassType()));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean checkArrayFieldAssignment(RegisterType.Category arrayFieldCategory,
|
||||
RegisterType.Category instructionCategory) {
|
||||
if (arrayFieldCategory == instructionCategory) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user