Skip to content

Commit 9532b69

Browse files
Raphael KimAndroid Build Coastguard Worker
authored andcommitted
[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:618767b6bf71b872399b57eb89c6724041258f45) Merged-In: I7ea5d5c1f78858db9865f3310d1e0aff9c8b5579 Change-Id: I7ea5d5c1f78858db9865f3310d1e0aff9c8b5579
1 parent 6a9250e commit 9532b69

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ public class CompanionDeviceManagerService extends SystemService {
126126
"debug.cdm.cdmservice.removal_time_window";
127127

128128
private static final long ASSOCIATION_REMOVAL_TIME_WINDOW_DEFAULT = DAYS.toMillis(90);
129+
private static final int MAX_CN_LENGTH = 500;
129130

130131
private PersistentDataStore mPersistentStore;
131132
private final PersistUserStateHandler mUserPersistenceHandler;
@@ -541,6 +542,9 @@ public PendingIntent requestNotificationAccess(ComponentName component, int user
541542
String callingPackage = component.getPackageName();
542543
checkCanCallNotificationApi(callingPackage);
543544
// TODO: check userId.
545+
if (component.flattenToString().length() > MAX_CN_LENGTH) {
546+
throw new IllegalArgumentException("Component name is too long.");
547+
}
544548
final long identity = Binder.clearCallingIdentity();
545549
try {
546550
return PendingIntent.getActivityAsUser(getContext(),

0 commit comments

Comments
 (0)