diff options
author | Nick Kralevich <nnk@google.com> | 2011-10-17 10:45:03 -0700 |
---|---|---|
committer | Nick Kralevich <nnk@google.com> | 2011-10-17 10:47:04 -0700 |
commit | 63f4a84104c228c74cdf132f5cef4f5184ae04bb (patch) | |
tree | db80bb6c9037ab3d0c737fbd18445e666c1dc7d1 /liblog/logprint.c | |
parent | 76feaf37218b7fec02ade30c143884df8299697c (diff) | |
download | core-63f4a84104c228c74cdf132f5cef4f5184ae04bb.tar.gz core-63f4a84104c228c74cdf132f5cef4f5184ae04bb.tar.bz2 core-63f4a84104c228c74cdf132f5cef4f5184ae04bb.zip |
liblog: ensure that the message length is consistent
When parsing log entries which may have embedded \0s, it's
possible for entry->messageLen to not be the actual
length of the string in entry->message. Detect this condition.
Bug: 5417417
Change-Id: I712cac7696af7831e24765b5a1b345d6ff5fb407
Diffstat (limited to 'liblog/logprint.c')
-rw-r--r-- | liblog/logprint.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/liblog/logprint.c b/liblog/logprint.c index 59fed9bc7..f2dd79fa1 100644 --- a/liblog/logprint.c +++ b/liblog/logprint.c @@ -374,6 +374,13 @@ int android_log_processLogBuffer(struct logger_entry *buf, entry->messageLen = buf->len - preambleAndNullLen; entry->message = entry->tag + tag_len + 1; + if (entry->messageLen != strlen(entry->message)) { + fprintf(stderr, + "+++ LOG: Message length inconsistent. Expected %d, got %d\n", + entry->messageLen, strlen(entry->message)); + return -1; + } + return 0; } @@ -830,7 +837,6 @@ char *android_log_formatLogLine ( while(pm < (entry->message + entry->messageLen)) { const char *lineStart; size_t lineLen; - lineStart = pm; // Find the next end-of-line in message |