fix(xml): AXML/Manifest parsing improvements (PR #2211)

* log and ignore decodeValue errors

* skip extra data in package header

* ResourceTypes.h
This commit is contained in:
Jan S 2024-07-06 18:27:47 +02:00 committed by GitHub
parent fd5b397b40
commit 96bd9f0f17
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 5 deletions

View File

@ -441,7 +441,13 @@ public class BinaryXMLParser extends CommonBinaryParser {
}
}
} 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);

View File

@ -12,7 +12,7 @@ public class 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;

View File

@ -123,8 +123,8 @@ public class ResTableBinaryParser extends CommonBinaryParser implements IResTabl
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 @@ public class ResTableBinaryParser extends CommonBinaryParser implements IResTabl
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) {