diff --git a/logd/LogKlog.cpp b/logd/LogKlog.cpp index d578c04db..d3a73a189 100644 --- a/logd/LogKlog.cpp +++ b/logd/LogKlog.cpp @@ -43,8 +43,10 @@ static char *is_prio(char *s) { if (!isdigit(*s++)) { return NULL; } + static const size_t max_prio_len = 4; + size_t len = 0; char c; - while ((c = *s++)) { + while (((c = *s++)) && (++len <= max_prio_len)) { if (!isdigit(c)) { return (c == '>') ? s : NULL; } @@ -73,7 +75,7 @@ static char *is_timestamp(char *s) { } // Like strtok_r with "\r\n" except that we look for log signatures (regex) -// \(\(<[0-9]+>\)\([[] *[0-9]+[.][0-9]+[]] \)\{0,1\}\|[[] *[0-9]+[.][0-9]+[]] \) +// \(\(<[0-9]\{1,4\}>\)\([[] *[0-9]+[.][0-9]+[]] \)\{0,1\}\|[[] *[0-9]+[.][0-9]+[]] \) // and split if we see a second one without a newline. #define SIGNATURE_MASK 0xF0 @@ -165,7 +167,7 @@ char *log_strtok_r(char *s, char **last) { break; } } - /* NOTREACHED */ + // NOTREACHED } log_time LogKlog::correction = log_time(CLOCK_REALTIME) - log_time(CLOCK_MONOTONIC); @@ -465,7 +467,7 @@ int LogKlog::log(const char *buf) { if (strncmp(bt, cp, size)) { // [