Resolve merge conflicts of e40a08509 to master

Test: gTest liblog-unit-tests logd-unit-tests logcat-unit-tests
Bug: 35373582
Bug: 34949125
Bug: 34606909
Change-Id: If6f3f138974913039dd49f2451bad6e413d6e2e1
diff --git a/logd/LogBuffer.cpp b/logd/LogBuffer.cpp
index 9c634f6..60d647d 100644
--- a/logd/LogBuffer.cpp
+++ b/logd/LogBuffer.cpp
@@ -157,8 +157,9 @@
             (lenl == sizeof(android_log_event_int_t)) &&
             !fastcmp<memcmp>(msgl, msgr, sizeof(android_log_event_int_t) -
                                              sizeof(int32_t)) &&
-            (elem->getTag() == LIBLOG_LOG_TAG))
+            (elem->getTag() == LIBLOG_LOG_TAG)) {
             return SAME_LIBLOG;
+        }
     }
 
     // audit message (except sequence number) identical?
@@ -166,8 +167,9 @@
 
     if (last->isBinary()) {
         if (fastcmp<memcmp>(msgl, msgr, sizeof(android_log_event_string_t) -
-                                            sizeof(int32_t)))
+                                            sizeof(int32_t))) {
             return DIFFERENT;
+        }
         msgl += sizeof(android_log_event_string_t);
         lenl -= sizeof(android_log_event_string_t);
         msgr += sizeof(android_log_event_string_t);
@@ -180,8 +182,13 @@
     if (!avcr) return DIFFERENT;
     lenr -= avcr - msgr;
     if (lenl != lenr) return DIFFERENT;
-    if (fastcmp<memcmp>(avcl + strlen(avc), avcr + strlen(avc), lenl))
+    // TODO: After b/35468874 is addressed, revisit "lenl > strlen(avc)"
+    // condition, it might become superflous.
+    if (lenl > strlen(avc) &&
+        fastcmp<memcmp>(avcl + strlen(avc), avcr + strlen(avc),
+                        lenl - strlen(avc))) {
         return DIFFERENT;
+    }
     return SAME;
 }