Skip to content

Commit 16d5a99

Browse files
committed
refactor: note that header skip happens too late on some
1 parent abaef3f commit 16d5a99

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/arsc/ARSCHeader.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,11 @@ public static ARSCHeader read(ExtDataInput in, CountingInputStream countIn) thro
5050
return new ARSCHeader(type, in.readShort(), in.readInt(), start);
5151
}
5252

53-
public void skipRemainingHeader(ExtDataInput in, CountingInputStream countIn) throws IOException {
53+
public void checkForUnreadChunk(ExtDataInput in, CountingInputStream countIn) throws IOException {
5454
// Some applications lie about the reported size of their chunk header. Trusting the chunkSize is misleading
5555
// So compare to what we actually read in the header vs reported and skip the rest.
56+
// However, this runs after each chunk and not every chunk reading has a specific distinction between the
57+
// header and the body.
5658
int actualHeaderSize = countIn.getCount() - this.startPosition;
5759
int exceedingSize = this.headerSize - actualHeaderSize;
5860
if (exceedingSize > 0) {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ private ResPackage[] readResourceTable() throws IOException, AndrolibException {
121121
break chunkLoop;
122122
}
123123

124-
// Check for chunks that are lying about their header size
125-
mHeader.skipRemainingHeader(mIn, mCountIn);
124+
mHeader.checkForUnreadChunk(mIn, mCountIn);
126125
}
127126

128127
if (mPkg.getResSpecCount() > 0) {

0 commit comments

Comments
 (0)