Merge "Add log summary to tombstones"
diff --git a/liblog/logprint.c b/liblog/logprint.c
index 59fed9b..daada5a 100644
--- a/liblog/logprint.c
+++ b/liblog/logprint.c
@@ -352,7 +352,6 @@
 {
     entry->tv_sec = buf->sec;
     entry->tv_nsec = buf->nsec;
-    entry->priority = buf->msg[0];
     entry->pid = buf->pid;
     entry->tid = buf->tid;
 
@@ -360,19 +359,32 @@
      * format: <priority:1><tag:N>\0<message:N>\0
      *
      * tag str
-     *   starts at msg+1
+     *   starts at buf->msg+1
      * msg
-     *   starts at msg+1+len(tag)+1
+     *   starts at buf->msg+1+len(tag)+1
      */
-    entry->tag = buf->msg + 1;
-    const size_t tag_len = strlen(entry->tag);
-    const size_t preambleAndNullLen = tag_len + 3;
-    if (buf->len <= preambleAndNullLen) {
-        fprintf(stderr, "+++ LOG: entry corrupt or truncated\n");
+    if (buf->len < 3) {
+        // An well-formed entry must consist of at least a priority
+        // and two null characters
+        fprintf(stderr, "+++ LOG: entry too small\n");
         return -1;
     }
-    entry->messageLen = buf->len - preambleAndNullLen;
-    entry->message = entry->tag + tag_len + 1;
+
+    int nullsFound = 0;
+    int i;
+    for (i = 1; i < buf->len; i++) {
+        if (buf->msg[i] == '\0') {
+            nullsFound++;
+        }
+    }
+    if (nullsFound != 2) {
+        fprintf(stderr, "+++ LOG: malformed log entry\n");
+        return -1;
+    }
+    entry->priority = buf->msg[0];
+    entry->tag = buf->msg + 1;
+    entry->message = entry->tag + strlen(entry->tag) + 1;
+    entry->messageLen = strlen(entry->message);
 
     return 0;
 }
@@ -830,7 +842,6 @@
         while(pm < (entry->message + entry->messageLen)) {
             const char *lineStart;
             size_t lineLen;
-
             lineStart = pm;
 
             // Find the next end-of-line in message
diff --git a/logcat/logcat.cpp b/logcat/logcat.cpp
index 4cd2151..ae56c41 100644
--- a/logcat/logcat.cpp
+++ b/logcat/logcat.cpp
@@ -296,6 +296,11 @@
                         fprintf(stderr, "read: Unexpected EOF!\n");
                         exit(EXIT_FAILURE);
                     }
+                    else if (entry->entry.len != ret - sizeof(struct logger_entry)) {
+                        fprintf(stderr, "read: unexpected length. Expected %d, got %d\n",
+                                entry->entry.len, ret - sizeof(struct logger_entry));
+                        exit(EXIT_FAILURE);
+                    }
 
                     entry->entry.msg[entry->entry.len] = '\0';
 
diff --git a/rootdir/init.rc b/rootdir/init.rc
index af4967e..3af0943 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -257,6 +257,7 @@
     setprop net.tcp.buffersize.wifi    524288,1048576,2097152,262144,524288,1048576
     setprop net.tcp.buffersize.lte     524288,1048576,2097152,262144,524288,1048576
     setprop net.tcp.buffersize.umts    4094,87380,110208,4096,16384,110208
+    setprop net.tcp.buffersize.hspa    4094,87380,262144,4096,16384,262144
     setprop net.tcp.buffersize.edge    4093,26280,35040,4096,16384,35040
     setprop net.tcp.buffersize.gprs    4092,8760,11680,4096,8760,11680