* fix: erroneous SignatureProcessor resolution of standard non-generic types with Annotation Signatures * ignore external and invalid class names in signature --------- Co-authored-by: Skylot <118523+skylot@users.noreply.github.com>
This commit is contained in:
@@ -9,6 +9,7 @@ import java.util.Set;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import jadx.core.deobf.NameMapper;
|
||||
import jadx.core.dex.info.MethodInfo;
|
||||
import jadx.core.dex.instructions.args.ArgType;
|
||||
import jadx.core.dex.nodes.ClassNode;
|
||||
@@ -167,7 +168,7 @@ public class SignatureProcessor extends AbstractVisitor {
|
||||
}
|
||||
ArgType type = root.getTypeUtils().expandTypeVariables(cls, signatureType);
|
||||
if (!validateParsedType(type, field.getType())) {
|
||||
cls.addWarnComment("Incorrect field signature: " + sp.getSignature());
|
||||
field.addInfoComment("Incorrect field signature: " + sp.getSignature());
|
||||
return;
|
||||
}
|
||||
field.updateType(type);
|
||||
@@ -256,9 +257,29 @@ public class SignatureProcessor extends AbstractVisitor {
|
||||
|
||||
private boolean validateParsedType(ArgType parsedType, ArgType currentType) {
|
||||
TypeCompareEnum result = root.getTypeCompare().compareTypes(parsedType, currentType);
|
||||
if (result == TypeCompareEnum.UNKNOWN
|
||||
&& parsedType.isObject()
|
||||
&& !validateFullClsName(parsedType.getObject())) {
|
||||
// ignore external invalid class names: may be a reserved words or garbage
|
||||
return false;
|
||||
}
|
||||
return result != TypeCompareEnum.CONFLICT;
|
||||
}
|
||||
|
||||
private boolean validateFullClsName(String fullClsName) {
|
||||
if (!NameMapper.isValidFullIdentifier(fullClsName)) {
|
||||
return false;
|
||||
}
|
||||
if (fullClsName.indexOf('.') > 0) {
|
||||
for (String namePart : fullClsName.split("\\.")) {
|
||||
if (!NameMapper.isValidIdentifier(namePart)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean validateInnerType(List<ArgType> types) {
|
||||
for (ArgType type : types) {
|
||||
if (!validateInnerType(type)) {
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package jadx.tests.integration.others;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jadx.tests.api.SmaliTest;
|
||||
|
||||
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
|
||||
|
||||
public class TestIncorrectFieldSignature extends SmaliTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
assertThat(getClassNodeFromSmali())
|
||||
.code()
|
||||
.containsOne("public static boolean A;")
|
||||
.containsOne("public static Boolean B;")
|
||||
.countString(2, "/* JADX INFO: Incorrect field signature:");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
.class public Lothers/TestIncorrectFieldSignature;
|
||||
.super Ljava/lang/Object;
|
||||
|
||||
.field public static A:Z
|
||||
.annotation system Ldalvik/annotation/Signature;
|
||||
value = {
|
||||
"Lint;"
|
||||
}
|
||||
.end annotation
|
||||
.end field
|
||||
|
||||
.field public static B:Ljava/lang/Boolean;
|
||||
.annotation system Ldalvik/annotation/Signature;
|
||||
value = {
|
||||
"Lpkg/int;"
|
||||
}
|
||||
.end annotation
|
||||
.end field
|
||||
Reference in New Issue
Block a user