Skip to content

Commit 955123a

Browse files
kjackalAndroid Build Coastguard Worker
authored andcommitted
[RESTRICT AUTOMERGE] Limit length of the name in <uses-permission>
To mitigate a boot loop with a huge name string, this CL restricts the max length of the name in <users-permission> attr. Bug: 259942609 Test: manually using the PoC in the buganizer to ensure the symptom no longer exists. Change-Id: I35dde9d6bea9eb7c1b81e8cbadeeb908b3fb713f (cherry picked from commit de8ef32) Merged-In: I35dde9d6bea9eb7c1b81e8cbadeeb908b3fb713f
1 parent 7a04bee commit 955123a

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

services/core/java/com/android/server/pm/pkg/parsing/ParsingPackageUtils.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ public class ParsingPackageUtils {
247247
private static final String MAX_NUM_COMPONENTS_ERR_MSG =
248248
"Total number of components has exceeded the maximum number: " + MAX_NUM_COMPONENTS;
249249

250+
/** The maximum permission name length. */
251+
private static final int MAX_PERMISSION_NAME_LENGTH = 512;
252+
250253
@IntDef(flag = true, prefix = { "PARSE_" }, value = {
251254
PARSE_CHATTY,
252255
PARSE_COLLECT_CERTIFICATES,
@@ -1275,6 +1278,11 @@ private ParseResult<ParsingPackage> parseUsesPermission(ParseInput input,
12751278
// that may change.
12761279
String name = sa.getNonResourceString(
12771280
R.styleable.AndroidManifestUsesPermission_name);
1281+
if (TextUtils.length(name) > MAX_PERMISSION_NAME_LENGTH) {
1282+
return input.error(INSTALL_PARSE_FAILED_MANIFEST_MALFORMED,
1283+
"The name in the <uses-permission> is greater than "
1284+
+ MAX_PERMISSION_NAME_LENGTH);
1285+
}
12781286

12791287
int maxSdkVersion = 0;
12801288
TypedValue val = sa.peekValue(

0 commit comments

Comments
 (0)