Skip to content

Commit

Permalink
fix(res): ignore reserved value in type chunk (PR #2403)
Browse files Browse the repository at this point in the history
fix: ignore reserved value in type chunk (fixes #2402)
  • Loading branch information
jpstotz authored Jan 29, 2025
1 parent 54fbbd9 commit 3d36c93
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,19 +240,19 @@ private void parseTypeChunk(long start, PackageChunk pkg) throws IOException {
// The type identifier this chunk is holding. Type IDs start at 1 (corresponding
// to the value of the type bits in a resource identifier). 0 is invalid.
int id = is.readInt8();
String typeName = pkg.getTypeStrings().get(id - 1);

int flags = is.readInt8();
boolean isSparse = (flags & FLAG_SPARSE) != 0;
boolean isOffset16 = (flags & FLAG_OFFSET16) != 0;

is.checkInt16(0, "type chunk, reserved");
is.readInt16(); // ignore reserved value - should be zero but in some apps it is not zero; see #2402
int entryCount = is.readInt32();
long entriesStart = start + is.readInt32();

EntryConfig config = parseConfig();

if (config.isInvalid) {
String typeName = pkg.getTypeStrings().get(id - 1);
LOG.warn("Invalid config flags detected: {}{}", typeName, config.getQualifiers());
}

Expand Down Expand Up @@ -285,7 +285,7 @@ private void parseTypeChunk(long start, PackageChunk pkg) throws IOException {
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 - index);
LOG.warn("End of chunk reached - ignoring remaining {} entries in type: {}", entryCount - index, typeName);
break;
}
long entryStartOffset = entriesStart + offset;
Expand Down

0 comments on commit 3d36c93

Please sign in to comment.