summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Raphael Kim <raphk@google.com> 2023-09-18 14:07:23 -0700
committer Raphael Kim <raphk@google.com> 2023-10-09 17:56:03 +0000
commite10f7d34dd843032e9d081e5a49e70f9d5d64bb6 (patch)
tree4ec6f14f0b2e0ee56877735bb1ba62fd8b3275cb
parent7235ee1800a2cdf5e628e76ce87da9996ed48246 (diff)
[CDM] Validate component name length before requesting notification access.
Bug: 295335110 Test: Test app with long component name Change-Id: I7ea5d5c1f78858db9865f3310d1e0aff9c8b5579 Merged-In: I7ea5d5c1f78858db9865f3310d1e0aff9c8b5579
-rw-r--r--services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java4
1 files changed, 4 insertions, 0 deletions
diff --git a/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java b/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
index 611541f671cf..0a617cdd2168 100644
--- a/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
+++ b/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
@@ -144,6 +144,7 @@ public class CompanionDeviceManagerService extends SystemService {
"debug.cdm.cdmservice.removal_time_window";
private static final long ASSOCIATION_REMOVAL_TIME_WINDOW_DEFAULT = DAYS.toMillis(90);
+ private static final int MAX_CN_LENGTH = 500;
private final ActivityManager mActivityManager;
private final OnPackageVisibilityChangeListener mOnPackageVisibilityChangeListener;
@@ -686,6 +687,9 @@ public class CompanionDeviceManagerService extends SystemService {
String callingPackage = component.getPackageName();
checkCanCallNotificationApi(callingPackage);
// TODO: check userId.
+ 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(),