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

Commit 0a1a9be4 authored by Marc Bächinger's avatar Marc Bächinger Committed by Android Build Coastguard Worker
Browse files

Check length of MBR component name properties

Test: Can't be tested on main as PackageManager prevents it
Flag: EXEMPT BUGFIX
Bug: 433250316
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:9062dd861d49627405804fcc9bb50fdae3701aa2
Merged-In: Ib3f0ec4277a468e4eb9b76604d5affd2568e8a3d
Change-Id: Ib3f0ec4277a468e4eb9b76604d5affd2568e8a3d
parent 5e541ac6
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ final class MediaButtonReceiverHolder {
    // Filter apps regardless of the phone's locked/unlocked state.
    private static final int PACKAGE_MANAGER_COMMON_FLAGS =
            PackageManager.MATCH_DIRECT_BOOT_AWARE | PackageManager.MATCH_DIRECT_BOOT_UNAWARE;

    private static final int MAX_COMPONENT_NAME_LENGTH = 1024;
    private final int mUserId;
    private final PendingIntent mPendingIntent;
    private final ComponentName mComponentName;
@@ -403,6 +403,13 @@ final class MediaButtonReceiverHolder {
            if (componentInfo != null && TextUtils.equals(componentInfo.packageName,
                    pendingIntent.getCreatorPackage())
                    && componentInfo.packageName != null && componentInfo.name != null) {
                int componentNameLength =
                        componentInfo.packageName.length() + componentInfo.name.length() + 1;
                if (componentNameLength > MAX_COMPONENT_NAME_LENGTH) {
                    Log.w(TAG, "detected and ignored component name with overly long package"
                            + " or name, pi=" + pendingIntent);
                    continue;
                }
                return new ComponentName(componentInfo.packageName, componentInfo.name);
            }
        }