Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2187a415 authored by Tom Cherry's avatar Tom Cherry
Browse files

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
parent 2beabe5c
Loading
Loading
Loading
Loading
+4 −21
Original line number Diff line number Diff line
@@ -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;
    }