liblog: fix prio and tag validation code

These checks are not needed; all callers are in this file and there's
only one possible situation: that we have valid pointers and sizes.

Test: liblog-unit-tests, log.tag.* properties still work
Change-Id: I8b385d5124c2d93cd99a352e30f745b075c8bd09
This commit is contained in:
Tom Cherry 2019-10-01 17:13:43 -07:00
parent 2beabe5c26
commit 2187a41586

View file

@ -280,28 +280,11 @@ static int __write_to_log_daemon(log_id_t log_id, struct iovec* vec, size_t nr)
return -EPERM;
}
} else {
/* Validate the incoming tag, tag content can not split across iovec */
char prio = ANDROID_LOG_VERBOSE;
const char* tag = static_cast<const char*>(vec[0].iov_base);
size_t len = vec[0].iov_len;
if (!tag) {
len = 0;
}
if (len > 0) {
prio = *tag;
if (len > 1) {
--len;
++tag;
} else {
len = vec[1].iov_len;
tag = ((const char*)vec[1].iov_base);
if (!tag) {
len = 0;
}
}
}
int prio = *static_cast<int*>(vec[0].iov_base);
const char* tag = static_cast<const char*>(vec[1].iov_base);
size_t len = vec[1].iov_len;
/* tag must be nul terminated */
if (tag && strnlen(tag, len) >= len) {
if (strnlen(tag, len) >= len) {
tag = NULL;
}