Skip to content

Commit a375717

Browse files
authored
fix: support alignment towards resTable_entry start (#3452)
1 parent bea15e6 commit a375717

File tree

1 file changed

+8
-1
lines changed
  • brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder

1 file changed

+8
-1
lines changed

brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ARSCDecoder.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ private ResType readTableType() throws IOException, AndrolibException {
275275
int typeFlags = mIn.readByte();
276276
mIn.skipBytes(2); // reserved
277277
int entryCount = mIn.readInt();
278-
mIn.skipInt(); // entriesStart
278+
int entriesStart = mIn.readInt();
279279

280280
ResConfigFlags flags = readConfigFlags();
281281

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

316+
// #3428 - In some applications the res entries are padded for alignment.
317+
int entriesStartAligned = mHeader.startPosition + entriesStart;
318+
if (mIn.position() < entriesStartAligned) {
319+
long bytesSkipped = mIn.skip(entriesStartAligned - mIn.position());
320+
LOGGER.fine("Skipping: " + bytesSkipped + " byte(s) to align with ResTable_entry start.");
321+
}
322+
316323
for (int i : entryOffsetMap.keySet()) {
317324
mResId = (mResId & 0xffff0000) | i;
318325
int offset = entryOffsetMap.get(i);

0 commit comments

Comments
 (0)