From 93114d53f99bea47be6893845c1e9f409f0445a4 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Thu, 1 Mar 2018 17:13:36 +0100 Subject: [PATCH] Fixed crash in log parser --- lib/util.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/util.cpp b/lib/util.cpp index 2f74ec70..9f03fa4a 100644 --- a/lib/util.cpp +++ b/lib/util.cpp @@ -292,7 +292,7 @@ namespace Util{ } //find end of line, insert null byte unsigned int j = i; - while (j < 1024 && buf[j] != '\n' && buf[j] != 0){++j;} + while (j < 1023 && buf[j] != '\n' && buf[j] != 0){++j;} buf[j] = 0; //print message if (message){ @@ -312,11 +312,11 @@ namespace Util{ timeinfo = localtime(&rawtime); strftime(buffer, 100, "%F %H:%M:%S", timeinfo); dprintf(out, "%s[%s] ", color_time, buffer); - if (strlen(progname) && strlen(progpid)){ + if (progname && progpid && strlen(progname) && strlen(progpid)){ dprintf(out, "%s (%s) ", progname, progpid); } dprintf(out, "%s%s: %s%s", color_msg, kind, message, color_end); - if (strlen(lineno)){ + if (lineno && strlen(lineno)){ dprintf(out, " (%s) ", lineno); } dprintf(out, "\n", lineno);