fix: only mark as sparse if intended application (#3299)

This commit is contained in:
Connor Tumbleson 2023-08-27 15:06:58 -04:00 committed by GitHub
parent 06c5f462e0
commit 81a7e1e434
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -270,7 +270,9 @@ public class ARSCDecoder {
mHeader.checkForUnreadHeader(mIn); mHeader.checkForUnreadHeader(mIn);
if ((typeFlags & 0x01) != 0) { // Be sure we don't poison mResTable by marking the application as sparse
// Only flag the ResTable as sparse if the main package is not loaded.
if ((typeFlags & 0x01) != 0 && !mResTable.isMainPkgLoaded()) {
mResTable.setSparseResources(true); mResTable.setSparseResources(true);
} }

View File

@ -54,6 +54,7 @@ public class SparseFlagTest extends BaseTest {
LOGGER.info("Decoding sparse.apk..."); LOGGER.info("Decoding sparse.apk...");
Config config = Config.getDefaultConfig(); Config config = Config.getDefaultConfig();
config.frameworkTag = "issue-3298";
ApkDecoder apkDecoder = new ApkDecoder(config, testApk); ApkDecoder apkDecoder = new ApkDecoder(config, testApk);
ApkInfo apkInfo = apkDecoder.decode(sTestNewDir); ApkInfo apkInfo = apkDecoder.decode(sTestNewDir);
@ -70,6 +71,7 @@ public class SparseFlagTest extends BaseTest {
LOGGER.info("Decoding not-sparse.apk..."); LOGGER.info("Decoding not-sparse.apk...");
Config config = Config.getDefaultConfig(); Config config = Config.getDefaultConfig();
config.frameworkTag = "issue-3298";
ApkDecoder apkDecoder = new ApkDecoder(config, testApk); ApkDecoder apkDecoder = new ApkDecoder(config, testApk);
ApkInfo apkInfo = apkDecoder.decode(sTestNewDir); ApkInfo apkInfo = apkDecoder.decode(sTestNewDir);