Skip to content

Commit

Permalink
fix: support alignment towards resTable_entry start (#3452)
Browse files Browse the repository at this point in the history
  • Loading branch information
iBotPeaches authored Dec 4, 2023
1 parent bea15e6 commit a375717
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ private ResType readTableType() throws IOException, AndrolibException {
int typeFlags = mIn.readByte();
mIn.skipBytes(2); // reserved
int entryCount = mIn.readInt();
mIn.skipInt(); // entriesStart
int entriesStart = mIn.readInt();

ResConfigFlags flags = readConfigFlags();

Expand Down Expand Up @@ -313,6 +313,13 @@ private ResType readTableType() throws IOException, AndrolibException {
mType = flags.isInvalid && !mKeepBroken ? null : mPkg.getOrCreateConfig(flags);
int noEntry = isOffset16 ? NO_ENTRY_OFFSET16 : NO_ENTRY;

// #3428 - In some applications the res entries are padded for alignment.
int entriesStartAligned = mHeader.startPosition + entriesStart;
if (mIn.position() < entriesStartAligned) {
long bytesSkipped = mIn.skip(entriesStartAligned - mIn.position());
LOGGER.fine("Skipping: " + bytesSkipped + " byte(s) to align with ResTable_entry start.");
}

for (int i : entryOffsetMap.keySet()) {
mResId = (mResId & 0xffff0000) | i;
int offset = entryOffsetMap.get(i);
Expand Down

0 comments on commit a375717

Please sign in to comment.