Fixed crash in log parser

This commit is contained in:
Thulinma 2018-03-01 17:13:36 +01:00
parent 564082f178
commit 93114d53f9

View file

@ -292,7 +292,7 @@ namespace Util{
} }
//find end of line, insert null byte //find end of line, insert null byte
unsigned int j = i; 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; buf[j] = 0;
//print message //print message
if (message){ if (message){
@ -312,11 +312,11 @@ namespace Util{
timeinfo = localtime(&rawtime); timeinfo = localtime(&rawtime);
strftime(buffer, 100, "%F %H:%M:%S", timeinfo); strftime(buffer, 100, "%F %H:%M:%S", timeinfo);
dprintf(out, "%s[%s] ", color_time, buffer); 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) ", progname, progpid);
} }
dprintf(out, "%s%s: %s%s", color_msg, kind, message, color_end); 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, " (%s) ", lineno);
} }
dprintf(out, "\n", lineno); dprintf(out, "\n", lineno);