From 069f22cf0c23a25a0eeb0967a0f3589206881e18 Mon Sep 17 00:00:00 2001 From: Jerome Gaillard Date: Tue, 22 Mar 2022 15:16:42 +0000 Subject: [PATCH] Read-only properties can have values of arbitrary length Read-only properties are defined by having a key starting with "ro.". Bug: 226123443 Change-Id: Ic91e0b7d57e614b620e5147f96356ffd7154daa2 --- core/java/android/os/SystemProperties.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/java/android/os/SystemProperties.java b/core/java/android/os/SystemProperties.java index ab741990430fc..82d4443ea7245 100644 --- a/core/java/android/os/SystemProperties.java +++ b/core/java/android/os/SystemProperties.java @@ -218,14 +218,15 @@ public class SystemProperties { /** * Set the value for the given {@code key} to {@code val}. * - * @throws IllegalArgumentException if the {@code val} exceeds 91 characters + * @throws IllegalArgumentException for non read-only properties if the {@code val} exceeds + * 91 characters * @throws RuntimeException if the property cannot be set, for example, if it was blocked by * SELinux. libc will log the underlying reason. * @hide */ @UnsupportedAppUsage public static void set(@NonNull String key, @Nullable String val) { - if (val != null && !val.startsWith("ro.") && val.length() > PROP_VALUE_MAX) { + if (val != null && !key.startsWith("ro.") && val.length() > PROP_VALUE_MAX) { throw new IllegalArgumentException("value of system property '" + key + "' is longer than " + PROP_VALUE_MAX + " characters: " + val); }