RESTRICT AUTOMERGE Validate permission tree size on permission update

Bug: 242537498
Test: atest PermissionMemoryFootprintTest
Change-Id: I15343e84c1802d6b89249106263319a6539fa73b
This commit is contained in:
Nate Myren
2022-09-22 15:23:24 -07:00
parent 3e1eabd934
commit 973c67f7fc

View File

@@ -644,8 +644,8 @@ public class PermissionManagerServiceImpl implements PermissionManagerServiceInt
Permission bp = mRegistry.getPermission(info.name); Permission bp = mRegistry.getPermission(info.name);
added = bp == null; added = bp == null;
int fixedLevel = PermissionInfo.fixProtectionLevel(info.protectionLevel); int fixedLevel = PermissionInfo.fixProtectionLevel(info.protectionLevel);
if (added) {
enforcePermissionCapLocked(info, tree); enforcePermissionCapLocked(info, tree);
if (added) {
bp = new Permission(info.name, tree.getPackageName(), Permission.TYPE_DYNAMIC); bp = new Permission(info.name, tree.getPackageName(), Permission.TYPE_DYNAMIC);
} else if (!bp.isDynamic()) { } else if (!bp.isDynamic()) {
throw new SecurityException("Not allowed to modify non-dynamic permission " throw new SecurityException("Not allowed to modify non-dynamic permission "