fix: support alignment towards resTable_entry start (#3452)

This commit is contained in:
Connor Tumbleson 2023-12-04 05:58:27 -05:00 committed by GitHub
parent bea15e6f12
commit a375717ade
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -275,7 +275,7 @@ public class ARSCDecoder {
int typeFlags = mIn.readByte();
mIn.skipBytes(2); // reserved
int entryCount = mIn.readInt();
mIn.skipInt(); // entriesStart
int entriesStart = mIn.readInt();
ResConfigFlags flags = readConfigFlags();
@ -313,6 +313,13 @@ public class ARSCDecoder {
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);