Skip to content

Commit

Permalink
refactor: note that header skip happens too late on some
Browse files Browse the repository at this point in the history
  • Loading branch information
iBotPeaches committed Jul 21, 2023
1 parent abaef3f commit 16d5a99
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ public static ARSCHeader read(ExtDataInput in, CountingInputStream countIn) thro
return new ARSCHeader(type, in.readShort(), in.readInt(), start);
}

public void skipRemainingHeader(ExtDataInput in, CountingInputStream countIn) throws IOException {
public void checkForUnreadChunk(ExtDataInput in, CountingInputStream countIn) throws IOException {
// Some applications lie about the reported size of their chunk header. Trusting the chunkSize is misleading
// So compare to what we actually read in the header vs reported and skip the rest.
// However, this runs after each chunk and not every chunk reading has a specific distinction between the
// header and the body.
int actualHeaderSize = countIn.getCount() - this.startPosition;
int exceedingSize = this.headerSize - actualHeaderSize;
if (exceedingSize > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ private ResPackage[] readResourceTable() throws IOException, AndrolibException {
break chunkLoop;
}

// Check for chunks that are lying about their header size
mHeader.skipRemainingHeader(mIn, mCountIn);
mHeader.checkForUnreadChunk(mIn, mCountIn);
}

if (mPkg.getResSpecCount() > 0) {
Expand Down

0 comments on commit 16d5a99

Please sign in to comment.