Merge pull request #2527 from LoyieKing/master

support lib/specType out-of-order reading - fix "Invalid chunk type: expected=0x00000200, got=0x00000203"
This commit is contained in:
Connor Tumbleson 2021-03-06 09:44:11 -05:00 committed by GitHub
commit 323935b995
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 7 deletions

View File

@ -123,12 +123,19 @@ public class ARSCDecoder {
mPkg = new ResPackage(mResTable, id, name);
nextChunk();
while (mHeader.type == Header.TYPE_LIBRARY) {
readLibraryType();
}
while (mHeader.type == Header.TYPE_SPEC_TYPE) {
readTableTypeSpec();
boolean flag = true;
while (flag) {
switch (mHeader.type) {
case Header.TYPE_LIBRARY:
readLibraryType();
break;
case Header.TYPE_SPEC_TYPE:
readTableTypeSpec();
break;
default:
flag = false;
break;
}
}
return mPkg;

View File

@ -302,8 +302,8 @@ public class StringBlock {
try {
return (m_isUTF8 ? UTF8_DECODER : UTF16LE_DECODER).decode(wrappedBuffer).toString();
} catch (CharacterCodingException ex) {
LOGGER.warning("Failed to decode a string at offset " + offset + " of length " + length);
if (!m_isUTF8) {
LOGGER.warning("Failed to decode a string at offset " + offset + " of length " + length);
return null;
}
}