Skip to content

Commit

Permalink
fix(res): resolve some manifest decode errors (PR #2122)
Browse files Browse the repository at this point in the history
* The elementSize may be larger than the actual size of the element chunk.

* end namespace chunk size can be any value.

* keep at least a warning.
  • Loading branch information
CKCat committed Mar 16, 2024
1 parent 8760b4d commit eecdfae
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,8 @@ private void parseNameSpaceEnd() throws IOException {
die("NAMESPACE end is not 0x10 big");
}
int dataSize = is.readInt32();
if (dataSize > 0x18) {
LOG.warn("Invalid namespace size");
} else if (dataSize < 0x18) {
die("NAMESPACE header chunk is not 0x18 big");
if (dataSize != 0x18) {
LOG.warn("Invalid namespace end size");
}
int endLineNumber = is.readInt32();
int comment = is.readInt32();
Expand Down Expand Up @@ -246,7 +244,8 @@ private void parseElement() throws IOException {
die("ELEMENT HEADER SIZE is not 0x10");
}
// TODO: Check element chunk size
is.readInt32();
long startPos = is.getPos();
int elementSize = is.readInt32();
int elementBegLineNumber = is.readInt32();
int comment = is.readInt32();
int startNS = is.readInt32();
Expand Down Expand Up @@ -291,6 +290,10 @@ private void parseElement() throws IOException {
for (int i = 0; i < attributeCount; i++) {
parseAttribute(i, attrNewLine, attrCache);
}
long endPos = is.getPos();
if (endPos - startPos + 0x4 < elementSize) {
is.skip(elementSize - (endPos - startPos + 0x4));
}
}

private void parseAttribute(int i, boolean newLine, Set<String> attrCache) throws IOException {
Expand Down

0 comments on commit eecdfae

Please sign in to comment.