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

Commit 4e0bd1e9 authored by Winson Chiu's avatar Winson Chiu
Browse files

Generalize canPackageQuery error message

This ensures no data leaks from reading the exception message.

Bug: 230868108

Test: manual, PoC from bug

Change-Id: I11963a0a9e429674732c51bd83898d0a8502ec04
parent a47d028e
Loading
Loading
Loading
Loading
+11 −15
Original line number Diff line number Diff line
@@ -5434,22 +5434,18 @@ public class ComputerEngine implements Computer {
                false /*checkShell*/, "may package query");
        final PackageStateInternal sourceSetting = getPackageStateInternal(sourcePackageName);
        final PackageStateInternal targetSetting = getPackageStateInternal(targetPackageName);
        if (sourceSetting == null || targetSetting == null) {
            throw new ParcelableException(new PackageManager.NameNotFoundException("Package(s) "
                    + (sourceSetting == null ? sourcePackageName + " " : "")
                    + (targetSetting == null ? targetPackageName + " " : "")
                    + "not found."));
        }
        boolean throwException = sourceSetting == null || targetSetting == null;
        if (!throwException) {
            final boolean filterSource =
                    shouldFilterApplication(sourceSetting, callingUid, userId);
            final boolean filterTarget =
                    shouldFilterApplication(targetSetting, callingUid, userId);
            // The caller must have visibility of the both packages
        if (filterSource || filterTarget) {
            throwException = filterSource || filterTarget;
        }
        if (throwException) {
            throw new ParcelableException(new PackageManager.NameNotFoundException("Package(s) "
                    + (filterSource ? sourcePackageName + " " : "")
                    + (filterTarget ? targetPackageName + " " : "")
                    + "not found."));
                    + sourcePackageName + " and/or " + targetPackageName + " not found."));
        }
        final int sourcePackageUid = UserHandle.getUid(userId, sourceSetting.getAppId());
        return !shouldFilterApplication(targetSetting, sourcePackageUid, userId);