From 46070505e771fb539748936dd6ac68aa77b9f422 Mon Sep 17 00:00:00 2001 From: Nick Kralevich Date: Mon, 17 Oct 2011 11:36:21 -0700 Subject: [PATCH] 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 --- logcat/logcat.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/logcat/logcat.cpp b/logcat/logcat.cpp index 4cd21514f..ae56c411b 100644 --- a/logcat/logcat.cpp +++ b/logcat/logcat.cpp @@ -296,6 +296,11 @@ static void readLogLines(log_device_t* devices) 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';