From a146a779e2154c51c87b140e06c456d010af1197 Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Fri, 5 Aug 2016 08:16:37 -0700 Subject: [PATCH] logd: klogd crash dmesg parser could wrap taglen limit resulting in out of bound accesses. Can lead to crash or data corruption. Fixed an issue with two-word tag parsing. Switched to case insensitive tag content matching. Added a few extra limit checks that could also wrap, simplified the parsing, then added means to stop using hard coded constants. Bug: 30688716 Bug: 30050636 Bug: 30614675 Bug: 25620123 Change-Id: Iae4f664f63ef7b842d82eaa1638b6d7a0d28fd18 --- logd/LogKlog.cpp | 196 +++++++++++++++++++++++------------------------ 1 file changed, 97 insertions(+), 99 deletions(-) diff --git a/logd/LogKlog.cpp b/logd/LogKlog.cpp index ac2b12895..0495463dc 100644 --- a/logd/LogKlog.cpp +++ b/logd/LogKlog.cpp @@ -605,126 +605,124 @@ int LogKlog::log(const char *buf, size_t len) { const char *tag = ""; const char *etag = tag; size_t taglen = len - (p - buf); - if (!isspace(*p) && *p) { - const char *bt, *et, *cp; + const char *bt = p; - bt = p; - if ((taglen >= 6) && !fast(p, "[INFO]", 6)) { - // [