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

Fix resource chunk loading (#751) #1436

Merged
merged 1 commit into from
Apr 4, 2022
Merged
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
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