logcat: add sanity check
Sanity check that the length we get back from the kernel matches
how much data we actually received.
Change-Id: I5cfd80321ab41459bb514dfde2da57413a7bd9e6
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';