Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 30611ae5 authored by Jackal Guo's avatar Jackal Guo
Browse files

Revise the IllegalArgumentException check

Combining the two IllegalArgumentException check in getKeySetByAlias
to mitigate the potential information leakage.

Bug: 189858116
Test: atest PackageManagerTests
Test: manually using the PoC in the buganizer to ensure the symptom
      no longer exists.
Change-Id: Id407900e156555db1ec6b87cbcd233a9976f242e
parent 96d2926f
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -26421,16 +26421,12 @@ public class PackageManagerService extends IPackageManager.Stub
        }
        synchronized(mLock) {
            final AndroidPackage pkg = mPackages.get(packageName);
            if (pkg == null) {
            if (pkg == null
                    || shouldFilterApplicationLocked(getPackageSetting(pkg.getPackageName()),
                    Binder.getCallingUid(), UserHandle.getCallingUserId())) {
                Slog.w(TAG, "KeySet requested for unknown package: " + packageName);
                throw new IllegalArgumentException("Unknown package: " + packageName);
            }
            final PackageSetting ps = getPackageSetting(pkg.getPackageName());
            if (shouldFilterApplicationLocked(
                    ps, Binder.getCallingUid(), UserHandle.getCallingUserId())) {
                Slog.w(TAG, "KeySet requested for filtered package: " + packageName);
                throw new IllegalArgumentException("Unknown package: " + packageName);
            }
            final KeySetManagerService ksms = mSettings.getKeySetManagerService();
            return new KeySet(ksms.getKeySetByAliasAndPackageNameLPr(packageName, alias));
        }