mirror of
https://github.com/revanced/smali.git
synced 2025-06-12 12:17:37 +02:00
Add additional checks for index size when writing various items
This commit is contained in:
@ -117,8 +117,20 @@ public class FieldIdItem extends Item<FieldIdItem> {
|
||||
out.annotate(4, "field_name: " + fieldName.getStringValue());
|
||||
}
|
||||
|
||||
out.writeShort(classType.getIndex());
|
||||
out.writeShort(fieldType.getIndex());
|
||||
int classIndex = classType.getIndex();
|
||||
if (classIndex > 0xffff) {
|
||||
throw new RuntimeException(String.format("Error writing field_id_item for %s. The type index of " +
|
||||
"defining class %s is too large", getFieldString(), classType.getTypeDescriptor()));
|
||||
}
|
||||
out.writeShort(classIndex);
|
||||
|
||||
int typeIndex = fieldType.getIndex();
|
||||
if (typeIndex > 0xffff) {
|
||||
throw new RuntimeException(String.format("Error writing field_id_item for %s. The type index of field " +
|
||||
"type %s is too large", getFieldString(), fieldType.getTypeDescriptor()));
|
||||
}
|
||||
out.writeShort(typeIndex);
|
||||
|
||||
out.writeInt(fieldName.getIndex());
|
||||
}
|
||||
|
||||
|
@ -112,8 +112,20 @@ public class MethodIdItem extends Item<MethodIdItem> {
|
||||
out.annotate(4, "method_name: " + methodName.getStringValue());
|
||||
}
|
||||
|
||||
out.writeShort(classType.getIndex());
|
||||
out.writeShort(methodPrototype.getIndex());
|
||||
int classIndex = classType.getIndex();
|
||||
if (classIndex > 0xffff) {
|
||||
throw new RuntimeException(String.format("Error writing method_id_item for %s. The type index of " +
|
||||
"defining class %s is too large", getMethodString(), classType.getTypeDescriptor()));
|
||||
}
|
||||
out.writeShort(classIndex);
|
||||
|
||||
int prototypeIndex = methodPrototype.getIndex();
|
||||
if (prototypeIndex > 0xffff) {
|
||||
throw new RuntimeException(String.format("Error writing method_id_item for %0. The prototype index of " +
|
||||
"method prototype %s is too large", getMethodString(), methodPrototype.getPrototypeString()));
|
||||
}
|
||||
out.writeShort(prototypeIndex);
|
||||
|
||||
out.writeInt(methodName.getIndex());
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,12 @@ public class TypeListItem extends Item<TypeListItem> {
|
||||
}
|
||||
out.writeInt(typeList.length);
|
||||
for (TypeIdItem typeIdItem: typeList) {
|
||||
out.writeShort(typeIdItem.getIndex());
|
||||
int typeIndex = typeIdItem.getIndex();
|
||||
if (typeIndex > 0xffff) {
|
||||
throw new RuntimeException(String.format("Error writing type_list entry. The type index of " +
|
||||
"type %s is too large", typeIdItem.getTypeDescriptor()));
|
||||
}
|
||||
out.writeShort(typeIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user