KMSG handling more robust. 43/88543/1
authorMichal Bloch <m.bloch@samsung.com>
Fri, 16 Sep 2016 15:55:21 +0000 (17:55 +0200)
committerMichal Bloch <m.bloch@samsung.com>
Mon, 19 Sep 2016 13:52:49 +0000 (15:52 +0200)
 * the parser handles malformed logs
 * util no longer discards parser result

Change-Id: I2e706b970b88717265f552703b0774a2e276519a
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
src/logutil/logutil.c
src/shared/queued_entry.c

index 2d7f2ef..27f55a2 100644 (file)
@@ -398,8 +398,12 @@ static void handle_pipe(struct fd_info **data_fds, int fd_count, int dump)
                fdi->index += r;
 
                e = (struct logger_entry *)fdi->buff;
-               if (fdi->type == KMSG)
-                       parse_kmsg_message(fdi->buff, 0, r);
+               if (fdi->type == KMSG) {
+                       if (!parse_kmsg_message(fdi->buff, 0, r)) {
+                               fdi->index = 0;
+                               continue;
+                       }
+               }
 
                if (fdi->type == KMSG || fdi->type == ANDROID_LOGGER)
                        e->len = r;
index b724571..3ce13f6 100644 (file)
@@ -140,14 +140,18 @@ int parse_kmsg_message(char * buffer, int prime, int buffer_size)
                le.tid = 0;
        } else {
                cptr = parse_dict_val(cptr+1, &cptr2);
-               if (cptr == NULL)
-                       return 0;
-               le.pid = strtol(cptr2, NULL, 10);
-
-               cptr = parse_dict_val(cptr, &cptr2);
-               if (cptr == NULL)
-                       return 0;
-               le.tid = strtol(cptr2, NULL, 10);
+               if (cptr == NULL) {
+                       le.pid = -1;
+                       le.tid = -1;
+               } else {
+                       le.pid = strtol(cptr2, NULL, 10);
+
+                       cptr = parse_dict_val(cptr, &cptr2);
+                       if (cptr == NULL)
+                               le.tid = -1;
+                       else
+                               le.tid = strtol(cptr2, NULL, 10);
+               }
        }
 
        prio = strtol(pri_begin, NULL, 10);