Hi,

 Android O removes 32 byte limit on system property names. This patch is
the follow up on this change fixing getprop and setprop toys accordingly.
From 3fd93922e01fa30c4ef8a4dd7182e5f9ee0fc3a6 Mon Sep 17 00:00:00 2001
From: Dimitry Ivanov <dimi...@google.com>
Date: Wed, 25 Jan 2017 13:27:03 -0800
Subject: [PATCH] Remove name length limit for system properties

Android O removes name length limit for system properties.

Use __system_property_read_callback instead of deprecated
__system_property_read in getprop and remove check for
property name length in setprop.

Test: adb shell setprop debug.test.very.very.long.property.name valueforpropertywithlongname
Test: adb shell getprop | grep debug.test.very.very.long.property.name
Bug: http://b/33926793
Change-Id: I57ca99ea33283d069cd1b7b9f110ec9fb27f3d19
---
 toys/android/getprop.c | 12 ++++++------
 toys/android/setprop.c |  3 ---
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/toys/android/getprop.c b/toys/android/getprop.c
index 390cb98..51e7344 100644
--- a/toys/android/getprop.c
+++ b/toys/android/getprop.c
@@ -39,13 +39,8 @@ static char *get_property_context(char *property)
   return context;
 }
 
-static void add_property(const prop_info *pi, void *unused)
+static void read_callback(void *unused, const char *name, const char *value)
 {
-  char name[PROP_NAME_MAX];
-  char value[PROP_VALUE_MAX];
-
-  __system_property_read(pi, name, value);
-
   if (!(TT.size&31)) TT.nv = xrealloc(TT.nv, (TT.size+32)*2*sizeof(char *));
 
   TT.nv[2*TT.size] = xstrdup(name);
@@ -56,6 +51,11 @@ static void add_property(const prop_info *pi, void *unused)
   }
 }
 
+static void add_property(const prop_info *pi, void *unused)
+{
+  __system_property_read_callback(pi, read_callback, NULL);
+}
+
 // Needed to supress extraneous "Loaded property_contexts from" message
 static int selinux_log_callback_local(int type, const char *fmt, ...)
 {
diff --git a/toys/android/setprop.c b/toys/android/setprop.c
index 2af314a..c135615 100644
--- a/toys/android/setprop.c
+++ b/toys/android/setprop.c
@@ -29,9 +29,6 @@ void setprop_main(void)
   // recognize most failures (because it doesn't wait for init), so
   // we duplicate all of init's checks here to help the user.
 
-  if (name_len >= PROP_NAME_MAX)
-    error_exit("name '%s' too long; try '%.*s'",
-               name, PROP_NAME_MAX - 1, name);
   if (value_len >= PROP_VALUE_MAX)
     error_exit("value '%s' too long; try '%.*s'",
                value, PROP_VALUE_MAX - 1, value);
-- 
2.11.0.483.g087da7b7c-goog

_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to