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

Commit 9f53cac1 authored by Mark Salyzyn's avatar Mark Salyzyn
Browse files

fix regression from android_lookupEventTag_len()

Commit 807e40ec 'liblog: logd: Add
android_lookupEventTag_len()' which addressed a Dirty Shared memory
leak resulted in a regression. Most notably logcat <tag> stopped
working for the events log buffer.

AndroidLogEntry::tag also requires callers to check out
AndroidLogEntry::tagLen as tag is no longer guaranteed to be
nul terminated.

Test: logcat-unit-tests --gtest_filter=logcat.event_tag_filter
Bug: 31456426
Change-Id: Ibe5236131b640eb5b7e3df0ab4b5f3e25b85ad45
parent 8cf0bd75
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -576,9 +576,9 @@ static void dump_log_file(
      AndroidLogEntry e;
      char buf[512];
      android_log_processBinaryLogBuffer(entry, &e, g_eventTagMap, buf, sizeof(buf));
      _LOG(log, logtype::LOGS, "%s.%03d %5d %5d %c %-8s: %s\n",
      _LOG(log, logtype::LOGS, "%s.%03d %5d %5d %c %-8.*s: %s\n",
         timeBuf, entry->nsec / 1000000, entry->pid, entry->tid,
         'I', e.tag, e.message);
         'I', (int)e.tagLen, e.tag, e.message);
      continue;
    }

+3 −1
Original line number Diff line number Diff line
@@ -187,7 +187,9 @@ static void processBuffer(log_device_t* dev, struct log_msg *buf)
        goto error;
    }

    if (android_log_shouldPrintLine(g_logformat, entry.tag, entry.priority)) {
    if (android_log_shouldPrintLine(g_logformat,
                                    std::string(entry.tag, entry.tagLen).c_str(),
                                    entry.priority)) {
        bool match = regexOk(entry);

        g_printCount += match;
+20 −0
Original line number Diff line number Diff line
@@ -79,6 +79,26 @@ TEST(logcat, buckets) {
    EXPECT_EQ(4, count);
}

TEST(logcat, event_tag_filter) {
    FILE *fp;

    ASSERT_TRUE(NULL != (fp = popen(
      "logcat -b events -d -s auditd am_proc_start am_pss am_proc_bound dvm_lock_sample am_wtf 2>/dev/null",
      "r")));

    char buffer[BIG_BUFFER];

    int count = 0;

    while (fgets(buffer, sizeof(buffer), fp)) {
        ++count;
    }

    pclose(fp);

    EXPECT_LT(4, count);
}

TEST(logcat, year) {

    if (android_log_clockid() == CLOCK_MONOTONIC) {