Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ac9bb90a authored by William Loh's avatar William Loh
Browse files

Add attribute validation for zygotePreloadName

The application tag attribute zygotePreloadName is a fully qualified
class name and needs to be validated.

Bug: 259946410
Test: atest AndroidPackageParsingValidationTest
Change-Id: Ieba5f450ffa64615c3a57fe7a8120bc79bf1b9c8
parent 027347e1
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -128,6 +128,7 @@ public class Element {
    protected static final String TAG_ATTR_VALUE = "value";
    protected static final String TAG_ATTR_VERSION_NAME = "versionName";
    protected static final String TAG_ATTR_WRITE_PERMISSION = "writePermission";
    protected static final String TAG_ATTR_ZYGOTE_PRELOAD_NAME = "zygotePreloadName";

    // The length of mTagCounters corresponds to the number of tags defined in getCounterIdx. If new
    // tags are added then the size here should be increased to match.
@@ -374,6 +375,7 @@ public class Element {
            case TAG_ATTR_TASK_AFFINITY:
            case TAG_ATTR_WRITE_PERMISSION:
            case TAG_ATTR_VERSION_NAME:
            case TAG_ATTR_ZYGOTE_PRELOAD_NAME:
                return MAX_ATTR_LEN_NAME;
            case TAG_ATTR_PATH:
            case TAG_ATTR_PATH_ADVANCED_PATTERN:
@@ -488,6 +490,7 @@ public class Element {
            case R.styleable.AndroidManifestApplication_requiredAccountType:
            case R.styleable.AndroidManifestApplication_restrictedAccountType:
            case R.styleable.AndroidManifestApplication_taskAffinity:
            case R.styleable.AndroidManifestApplication_zygotePreloadName:
                return MAX_ATTR_LEN_NAME;
            default:
                return DEFAULT_MAX_STRING_ATTR_LENGTH;
@@ -738,6 +741,7 @@ public class Element {
                switch (name) {
                    case TAG_ATTR_BACKUP_AGENT:
                    case TAG_ATTR_NAME:
                    case TAG_ATTR_ZYGOTE_PRELOAD_NAME:
                        return true;
                    default:
                        return false;
@@ -766,7 +770,8 @@ public class Element {
                return index == R.styleable.AndroidManifestActivityAlias_targetActivity;
            case TAG_APPLICATION:
                return index == R.styleable.AndroidManifestApplication_backupAgent
                        || index == R.styleable.AndroidManifestApplication_name;
                        || index == R.styleable.AndroidManifestApplication_name
                        || index == R.styleable.AndroidManifestApplication_zygotePreloadName;
            case TAG_INSTRUMENTATION:
                return index ==  R.styleable.AndroidManifestInstrumentation_name;
            case TAG_PROVIDER:
+11 −0
Original line number Diff line number Diff line
@@ -138,6 +138,17 @@ class AndroidPackageParsingValidationTest {
            R.styleable.AndroidManifestApplication_taskAffinity,
            1024
        )
        validateTagAttr(
            tag,
            "zygotePreloadName",
            R.styleable.AndroidManifestApplication_zygotePreloadName,
            1024
        )
        validateTagAttrComponentName(
            tag,
            "zygotePreloadName",
            R.styleable.AndroidManifestApplication_zygotePreloadName
        )
        validateTagCount("profileable", 100, tag)
        validateTagCount("uses-native-library", 100, tag)
        validateTagCount("receiver", 1000, tag)