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

Commit 0f1b69be authored by Raphael Kim's avatar Raphael Kim
Browse files

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

Bug: 295335110
Test: Test app with long component name
Change-Id: I7ea5d5c1f78858db9865f3310d1e0aff9c8b5579
Merged-In: I7ea5d5c1f78858db9865f3310d1e0aff9c8b5579
parent 230e00c8
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -173,6 +173,7 @@ public class CompanionDeviceManagerService extends SystemService implements Bind

    private static final int ASSOCIATE_WITHOUT_PROMPT_MAX_PER_TIME_WINDOW = 5;
    private static final long ASSOCIATE_WITHOUT_PROMPT_WINDOW_MS = 60 * 60 * 1000; // 60 min;
    private static final int MAX_CN_LENGTH = 500;

    private static final String XML_TAG_ASSOCIATIONS = "associations";
    private static final String XML_TAG_ASSOCIATION = "association";
@@ -561,6 +562,9 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
                                    PackageItemInfo.SAFE_LABEL_FLAG_TRIM
                                            | PackageItemInfo.SAFE_LABEL_FLAG_FIRST_LINE)
                            .toString());
            if (component.flattenToString().length() > MAX_CN_LENGTH) {
                throw new IllegalArgumentException("Component name is too long.");
            }
            final long identity = Binder.clearCallingIdentity();
            try {
                return PendingIntent.getActivityAsUser(getContext(),