Fix security bug: collect certs for non-systemDir apks.

ag/3340390 changed untrusted value to systemDir while going through
code review, flipping the meaning of the variable, but this was not
reflected in the call site.  As a result, systemDir apps are the
only ones being fully verified, which is the opposite of what we want.

Test: Builds, eventually CTS.

Change-Id: I585ac65c957f0d8db6c73f003d3a3eb2b79c8883
This commit is contained in:
Dan Cashman
2017-12-14 13:32:49 -08:00
parent 1418d5a1bb
commit 63addbd363

View File

@@ -1559,7 +1559,7 @@ public class PackageParser {
throws PackageParserException {
final String apkPath = apkFile.getAbsolutePath();
boolean untrusted = (parseFlags & PARSE_IS_SYSTEM_DIR) == 0;
boolean systemDir = (parseFlags & PARSE_IS_SYSTEM_DIR) != 0;
int minSignatureScheme = ApkSignatureVerifier.VERSION_JAR_SIGNATURE_SCHEME;
if ((parseFlags & PARSE_IS_EPHEMERAL) != 0 || pkg.applicationInfo.isStaticSharedLibrary()) {
// must use v2 signing scheme
@@ -1567,7 +1567,7 @@ public class PackageParser {
}
try {
ApkSignatureVerifier.Result verified =
ApkSignatureVerifier.verify(apkPath, minSignatureScheme, untrusted);
ApkSignatureVerifier.verify(apkPath, minSignatureScheme, systemDir);
if (pkg.mCertificates == null) {
pkg.mCertificates = verified.certs;
pkg.mSignatures = verified.sigs;