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

Commit 3dadbf43 authored by Raphael Kim's avatar Raphael Kim Committed by Android Build Coastguard Worker
Browse files

[CDM] Validate component name length before requesting notification access.

Bug: 295335110
Test: Test app with long component name
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:447216ecbe5f22ea06379d9587dae530b1202fe8)
Merged-In: I7ea5d5c1f78858db9865f3310d1e0aff9c8b5579
Change-Id: I7ea5d5c1f78858db9865f3310d1e0aff9c8b5579
parent 6297ade0
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -120,6 +120,7 @@ public class CompanionDeviceManagerService extends SystemService implements Bind


    private static final String PREF_FILE_NAME = "companion_device_preferences.xml";
    private static final String PREF_FILE_NAME = "companion_device_preferences.xml";
    private static final String PREF_KEY_AUTO_REVOKE_GRANTS_DONE = "auto_revoke_grants_done";
    private static final String PREF_KEY_AUTO_REVOKE_GRANTS_DONE = "auto_revoke_grants_done";
    private static final int MAX_CN_LENGTH = 500;


    private static final String XML_TAG_ASSOCIATIONS = "associations";
    private static final String XML_TAG_ASSOCIATIONS = "associations";
    private static final String XML_TAG_ASSOCIATION = "association";
    private static final String XML_TAG_ASSOCIATION = "association";
@@ -383,6 +384,9 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
            String callingPackage = component.getPackageName();
            String callingPackage = component.getPackageName();
            checkCanCallNotificationApi(callingPackage);
            checkCanCallNotificationApi(callingPackage);
            int userId = getCallingUserId();
            int userId = getCallingUserId();
            if (component.flattenToString().length() > MAX_CN_LENGTH) {
                throw new IllegalArgumentException("Component name is too long.");
            }
            final long identity = Binder.clearCallingIdentity();
            final long identity = Binder.clearCallingIdentity();
            try {
            try {
                return PendingIntent.getActivity(getContext(),
                return PendingIntent.getActivity(getContext(),