summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Salyzyn2017-04-05 12:11:09 -0500
committerMark Salyzyn2017-04-07 13:18:18 -0500
commitd24dc95e871e8d201e894b36f4cd102af226287e (patch)
treee86292d22f8bdd5d9490bd7bc4dc9dbd22dcce97 /liblog/properties.c
parentacc0e98b0f07c7296a019b40fa4cdf02d5cf21b4 (diff)
downloadplatform-system-core-d24dc95e871e8d201e894b36f4cd102af226287e.tar.gz
platform-system-core-d24dc95e871e8d201e894b36f4cd102af226287e.tar.xz
platform-system-core-d24dc95e871e8d201e894b36f4cd102af226287e.zip
liblog: adapt to removal of property name size limit
There is no longer a name size limit to the properties. Test: gTest liblog-unit-tests, logd-unit-tests and logcat-unit-tests Test: liblog-benchmarks BM_is_loggable Bug: 36696208 Change-Id: I80706a48583192b21f532a06cb8fa183a34e5f76
Diffstat (limited to 'liblog/properties.c')
-rw-r--r--liblog/properties.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/liblog/properties.c b/liblog/properties.c
index 0b0ef5205..adf19002e 100644
--- a/liblog/properties.c
+++ b/liblog/properties.c
@@ -95,7 +95,7 @@ static int __android_log_level(const char* tag, size_t len, int default_prio) {
95 /* calculate the size of our key temporary buffer */ 95 /* calculate the size of our key temporary buffer */
96 const size_t taglen = tag ? len : 0; 96 const size_t taglen = tag ? len : 0;
97 /* sizeof(log_namespace) = strlen(log_namespace) + 1 */ 97 /* sizeof(log_namespace) = strlen(log_namespace) + 1 */
98 char key[sizeof(log_namespace) + taglen]; /* may be > PROP_NAME_MAX */ 98 char key[sizeof(log_namespace) + taglen];
99 char* kp; 99 char* kp;
100 size_t i; 100 size_t i;
101 char c = 0; 101 char c = 0;
@@ -108,7 +108,8 @@ static int __android_log_level(const char* tag, size_t len, int default_prio) {
108 * Where the missing tag matches all tags and becomes the 108 * Where the missing tag matches all tags and becomes the
109 * system global default. We do not support ro.log.tag* . 109 * system global default. We do not support ro.log.tag* .
110 */ 110 */
111 static char last_tag[PROP_NAME_MAX]; 111 static char* last_tag;
112 static size_t last_tag_len;
112 static uint32_t global_serial; 113 static uint32_t global_serial;
113 /* some compilers erroneously see uninitialized use. !not_locked */ 114 /* some compilers erroneously see uninitialized use. !not_locked */
114 uint32_t current_global_serial = 0; 115 uint32_t current_global_serial = 0;
@@ -147,25 +148,29 @@ static int __android_log_level(const char* tag, size_t len, int default_prio) {
147 if (taglen) { 148 if (taglen) {
148 int local_change_detected = change_detected; 149 int local_change_detected = change_detected;
149 if (!not_locked) { 150 if (!not_locked) {
150 if (!last_tag[0] || (last_tag[0] != tag[0]) || 151 if (!last_tag || !last_tag[0] || (last_tag[0] != tag[0]) ||
151 strncmp( 152 strncmp(last_tag + 1, tag + 1, last_tag_len - 1)) {
152 last_tag + 1, tag + 1,
153 (len < sizeof(last_tag)) ? (len - 1) : (sizeof(last_tag) - 1)) ||
154 ((len < sizeof(last_tag)) && last_tag[len])) {
155 /* invalidate log.tag.<tag> cache */ 153 /* invalidate log.tag.<tag> cache */
156 for (i = 0; i < (sizeof(tag_cache) / sizeof(tag_cache[0])); ++i) { 154 for (i = 0; i < (sizeof(tag_cache) / sizeof(tag_cache[0])); ++i) {
157 tag_cache[i].cache.pinfo = NULL; 155 tag_cache[i].cache.pinfo = NULL;
158 tag_cache[i].c = '\0'; 156 tag_cache[i].c = '\0';
159 } 157 }
160 last_tag[0] = '\0'; 158 if (last_tag) last_tag[0] = '\0';
161 local_change_detected = 1; 159 local_change_detected = 1;
162 } 160 }
163 if (!last_tag[0]) { 161 if (!last_tag || !last_tag[0]) {
164 if (len < sizeof(last_tag)) { 162 if (!last_tag) {
163 last_tag = calloc(1, len + 1);
164 last_tag_len = 0;
165 if (last_tag) last_tag_len = len + 1;
166 } else if (len >= last_tag_len) {
167 last_tag = realloc(last_tag, len + 1);
168 last_tag_len = 0;
169 if (last_tag) last_tag_len = len + 1;
170 }
171 if (last_tag) {
165 strncpy(last_tag, tag, len); 172 strncpy(last_tag, tag, len);
166 last_tag[len] = '\0'; 173 last_tag[len] = '\0';
167 } else {
168 strncpy(last_tag, tag, sizeof(last_tag));
169 } 174 }
170 } 175 }
171 } 176 }
@@ -435,7 +440,7 @@ LIBLOG_ABI_PRIVATE bool __android_logger_property_get_bool(const char* key,
435 int flag) { 440 int flag) {
436 struct cache_property property = { { NULL, -1 }, { 0 } }; 441 struct cache_property property = { { NULL, -1 }, { 0 } };
437 if (flag & BOOL_DEFAULT_FLAG_PERSIST) { 442 if (flag & BOOL_DEFAULT_FLAG_PERSIST) {
438 char newkey[PROP_NAME_MAX]; 443 char newkey[strlen("persist.") + strlen(key) + 1];
439 snprintf(newkey, sizeof(newkey), "ro.%s", key); 444 snprintf(newkey, sizeof(newkey), "ro.%s", key);
440 refresh_cache_property(&property, newkey); 445 refresh_cache_property(&property, newkey);
441 property.cache.pinfo = NULL; 446 property.cache.pinfo = NULL;
@@ -600,8 +605,8 @@ LIBLOG_ABI_PRIVATE unsigned long __android_logger_get_buffer_size(log_id_t logId
600 evaluate_property_get_size 605 evaluate_property_get_size
601 /* clang-format on */ 606 /* clang-format on */
602 }; 607 };
603 char key_persist[PROP_NAME_MAX]; 608 char key_persist[strlen(global_tunable) + strlen(".security") + 1];
604 char key_ro[PROP_NAME_MAX]; 609 char key_ro[strlen(global_default) + strlen(".security") + 1];
605 struct cache2_property_size local = { 610 struct cache2_property_size local = {
606 /* clang-format off */ 611 /* clang-format off */
607 PTHREAD_MUTEX_INITIALIZER, 0, 612 PTHREAD_MUTEX_INITIALIZER, 0,