Merge "DO NOT MERGE: Revert "delete libnl_2""
diff --git a/logcat/logcat.cpp b/logcat/logcat.cpp
index 5960609..5a80efe 100644
--- a/logcat/logcat.cpp
+++ b/logcat/logcat.cpp
@@ -807,7 +807,10 @@
         // squash out the byte count
         cp = buf;
         if (!truncated) {
-            while (isdigit(*cp) || (*cp == '\n')) {
+            while (isdigit(*cp)) {
+                ++cp;
+            }
+            if (*cp == '\n') {
                 ++cp;
             }
         }
diff --git a/logcat/tests/logcat_test.cpp b/logcat/tests/logcat_test.cpp
index 818a978..958948b 100644
--- a/logcat/tests/logcat_test.cpp
+++ b/logcat/tests/logcat_test.cpp
@@ -343,7 +343,6 @@
     signal(SIGALRM, caught_blocking);
     alarm(2);
     while (fgets(buffer, sizeof(buffer), fp)) {
-        alarm(2);
 
         if (!strncmp(buffer, "DONE", 4)) {
             break;
@@ -413,7 +412,6 @@
     signal(SIGALRM, caught_blocking_tail);
     alarm(2);
     while (fgets(buffer, sizeof(buffer), fp)) {
-        alarm(2);
 
         if (!strncmp(buffer, "DONE", 4)) {
             break;
@@ -484,7 +482,6 @@
     signal(SIGALRM, caught_blocking_clear);
     alarm(2);
     while (fgets(buffer, sizeof(buffer), fp)) {
-        alarm(2);
 
         if (!strncmp(buffer, "clearLog: ", 10)) {
             fprintf(stderr, "WARNING: Test lacks permission to run :-(\n");
@@ -601,7 +598,7 @@
 
     ASSERT_EQ(true, get_white_black(&list));
 
-    static const char adjustment[] = "~! ~1000";
+    static const char adjustment[] = "~! 300/20 300/25 2000 ~1000/5 ~1000/30";
     ASSERT_EQ(true, set_white_black(adjustment));
     ASSERT_EQ(true, get_white_black(&adjust));
     if (strcmp(adjustment, adjust)) {
@@ -611,6 +608,16 @@
     free(adjust);
     adjust = NULL;
 
+    static const char adjustment2[] = "300/20 300/21 2000 ~1000";
+    ASSERT_EQ(true, set_white_black(adjustment2));
+    ASSERT_EQ(true, get_white_black(&adjust));
+    if (strcmp(adjustment2, adjust)) {
+        fprintf(stderr, "ERROR: '%s' != '%s'\n", adjustment2, adjust);
+    }
+    ASSERT_STREQ(adjustment2, adjust);
+    free(adjust);
+    adjust = NULL;
+
     ASSERT_EQ(true, set_white_black(list));
     ASSERT_EQ(true, get_white_black(&adjust));
     if (strcmp(list, adjust)) {
diff --git a/logd/LogListener.cpp b/logd/LogListener.cpp
index bef2097..874302a 100644
--- a/logd/LogListener.cpp
+++ b/logd/LogListener.cpp
@@ -95,7 +95,9 @@
     msg += sizeof(log_time);
     n -= sizeof(log_time);
 
-    unsigned short len = n;
+    // NB: hdr.msg_flags & MSG_TRUNC is not tested, silently passing a
+    // truncated message to the logs.
+    unsigned short len = n; // cap to internal maximum
     if (len == n) {
         logbuf->log(log_id, realtime, cred->uid, cred->pid, tid, msg, len);
         reader->notifyNewLog();
diff --git a/logd/LogWhiteBlackList.cpp b/logd/LogWhiteBlackList.cpp
index d0ceb9f..5f8173f 100644
--- a/logd/LogWhiteBlackList.cpp
+++ b/logd/LogWhiteBlackList.cpp
@@ -154,8 +154,8 @@
                 }
                 m = pid - p->mPid;
             }
-            if (m >= 0) {
-                if (m > 0) {
+            if (m <= 0) {
+                if (m < 0) {
                     list->insert(it, new Prune(uid,pid));
                 }
                 break;