diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ARSCDecoder.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ARSCDecoder.java index 9e0dcf2a1a..24bfe96437 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ARSCDecoder.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ARSCDecoder.java @@ -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(); @@ -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);