Skip to content

Commit

Permalink
fix(res): ignore resource chunk entries that are located after the re…
Browse files Browse the repository at this point in the history
…source chunk end (#751)(PR #1436)
  • Loading branch information
jpstotz committed Apr 4, 2022
1 parent 9a9ac43 commit 8551c6c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions jadx-core/src/main/java/jadx/core/xmlgen/ResTableParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ private void parseTypeChunk(long start, PackageChunk pkg) throws IOException {
/* int headerSize = */
is.readInt16();
/* int size = */
is.readInt32();
long chunkSize = is.readUInt32();
long chunkEnd = start + chunkSize;

int id = is.readInt8();
is.checkInt8(0, "type chunk, res0");
Expand All @@ -231,10 +232,15 @@ private void parseTypeChunk(long start, PackageChunk pkg) throws IOException {
for (int i = 0; i < entryCount; i++) {
entryIndexes[i] = is.readInt32();
}

is.checkPos(entriesStart, "Expected entry start");
for (int i = 0; i < entryCount; i++) {
if (entryIndexes[i] != NO_ENTRY) {
if (is.getPos() >= chunkEnd) {
// Certain resource obfuscated apps like com.facebook.orca have more entries defined
// than actually fit into the chunk size -> ignore the remaining entries
LOG.warn("End of chunk reached - ignoring remaining {} entries", entryCount - i);
break;
}
parseEntry(pkg, id, i, config.getQualifiers());
}
}
Expand Down

0 comments on commit 8551c6c

Please sign in to comment.