diff options
author | Dianne Hackborn <hackbod@android.com> | 2011-07-25 12:21:32 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-07-25 12:21:32 -0700 |
commit | 1b20abd30c2757132b7a2d319ae73f420b864ed4 (patch) | |
tree | 28951ac14dd8195cdab832ff0c1d74259d87b89b | |
parent | 6d21aee882215e8a17408f6ae1fbfba5cf8e440f (diff) | |
parent | 20bf46af14130314ae1aeb1e5482c38556c8f0f8 (diff) | |
download | frameworks_base-1b20abd30c2757132b7a2d319ae73f420b864ed4.zip frameworks_base-1b20abd30c2757132b7a2d319ae73f420b864ed4.tar.gz frameworks_base-1b20abd30c2757132b7a2d319ae73f420b864ed4.tar.bz2 |
am 20bf46af: am b0878223: am 6800a801: Merge "frameworks/base: Cap the number of toasts that a package can post."
* commit '20bf46af14130314ae1aeb1e5482c38556c8f0f8':
frameworks/base: Cap the number of toasts that a package can post.
-rwxr-xr-x | services/java/com/android/server/NotificationManagerService.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java index e738145..37b6611 100755 --- a/services/java/com/android/server/NotificationManagerService.java +++ b/services/java/com/android/server/NotificationManagerService.java @@ -483,6 +483,24 @@ public class NotificationManagerService extends INotificationManager.Stub record = mToastQueue.get(index); record.update(duration); } else { + // Limit the number of toasts that any given package except the android + // package can enqueue. Prevents DOS attacks and deals with leaks. + if (!"android".equals(pkg)) { + int count = 0; + final int N = mToastQueue.size(); + for (int i=0; i<N; i++) { + final ToastRecord r = mToastQueue.get(i); + if (r.pkg.equals(pkg)) { + count++; + if (count >= MAX_PACKAGE_NOTIFICATIONS) { + Slog.e(TAG, "Package has already posted " + count + + " toasts. Not showing more. Package=" + pkg); + return; + } + } + } + } + record = new ToastRecord(callingPid, pkg, callback, duration); mToastQueue.add(record); index = mToastQueue.size() - 1; |