Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More AXML/Manifest parsing improvements #2211

Merged
merged 3 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
Loading