diff --git a/jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java b/jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java index 203f127e6cc..5c7fec7d8ea 100644 --- a/jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java +++ b/jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java @@ -441,7 +441,13 @@ private void decodeAttribute(int attributeNS, int attrValDataType, int attrValDa } } } else { - String str = valuesParser.decodeValue(attrValDataType, attrValData); + String str; + try { + str = valuesParser.decodeValue(attrValDataType, attrValData); + } catch (JadxRuntimeException e) { + LOG.error("Failed to decode attribute value of \"{}\"", attrFullName, e); + str = null; + } memorizePackageName(attrFullName, str); if (isDeobfCandidateAttr(attrFullName)) { str = deobfClassName(str); diff --git a/jadx-core/src/main/java/jadx/core/xmlgen/ParserConstants.java b/jadx-core/src/main/java/jadx/core/xmlgen/ParserConstants.java index 239b832e1bc..bef8dc58e00 100644 --- a/jadx-core/src/main/java/jadx/core/xmlgen/ParserConstants.java +++ b/jadx-core/src/main/java/jadx/core/xmlgen/ParserConstants.java @@ -12,7 +12,7 @@ protected ParserConstants() { protected static final String ANDROID_NS_VALUE = "android"; /** - * Chunk types + * Chunk types as defined in frameworks/base/libs/androidfw/include/androidfw/ResourceTypes.h (AOSP) */ protected static final int RES_NULL_TYPE = 0x0000; protected static final int RES_STRING_POOL_TYPE = 0x0001; diff --git a/jadx-core/src/main/java/jadx/core/xmlgen/ResTableBinaryParser.java b/jadx-core/src/main/java/jadx/core/xmlgen/ResTableBinaryParser.java index d69acfb7af4..dd6049c1a7e 100644 --- a/jadx-core/src/main/java/jadx/core/xmlgen/ResTableBinaryParser.java +++ b/jadx-core/src/main/java/jadx/core/xmlgen/ResTableBinaryParser.java @@ -123,8 +123,8 @@ private PackageChunk parsePackage() throws IOException { long start = is.getPos(); is.checkInt16(RES_TABLE_PACKAGE_TYPE, "Not a table chunk"); int headerSize = is.readInt16(); - if (headerSize != 0x011c && headerSize != 0x0120) { - die("Unexpected package header size"); + if (headerSize < 0x011c) { + die("Package header size too small"); } long size = is.readUInt32(); long endPos = start + size; @@ -138,10 +138,12 @@ private PackageChunk parsePackage() throws IOException { long keyStringsOffset = start + is.readInt32(); /* int lastPublicKey = */ is.readInt32(); - if (headerSize == 0x0120) { + + if (headerSize >= 0x0120) { /* int typeIdOffset = */ is.readInt32(); } + is.skipToPos(start + headerSize, "package header end"); BinaryXMLStrings typeStrings = null; if (typeStringsOffset != 0) {