summaryrefslogtreecommitdiffstats
path: root/liblog
diff options
context:
space:
mode:
authorMark Salyzyn2017-04-10 16:15:26 -0500
committerAndroid (Google) Code Review2017-04-10 16:15:27 -0500
commitb07c58758bd1b2ea67d89e75949c821548637d55 (patch)
tree951ff421e773229b620915efc52d13fac7c21a6e /liblog
parentffa763208ba445d4fcbf8759728c84b83b0b1e4b (diff)
parentc18f3102da853b49e51c17c26b5bd5e7f0c90478 (diff)
downloadplatform-system-core-b07c58758bd1b2ea67d89e75949c821548637d55.tar.gz
platform-system-core-b07c58758bd1b2ea67d89e75949c821548637d55.tar.xz
platform-system-core-b07c58758bd1b2ea67d89e75949c821548637d55.zip
Merge "liblog: adapt to removal of property name size limit" into oc-dev
Diffstat (limited to 'liblog')
-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,