From: Pierre Ossman Date: Thu, 1 Nov 2018 15:04:30 +0000 (+0100) Subject: Handle line breaks in log messages X-Git-Tag: v1.9.90~48^2~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=46c2c4627340c0c107ce31b95806ab77c157d3a6;p=tigervnc.git Handle line breaks in log messages --- diff --git a/common/rfb/Logger.cxx b/common/rfb/Logger.cxx index 3daf2486..ad10a4cf 100644 --- a/common/rfb/Logger.cxx +++ b/common/rfb/Logger.cxx @@ -47,7 +47,16 @@ void Logger::write(int level, const char *logname, const char* format, char buf1[4096]; vsnprintf(buf1, sizeof(buf1)-1, format, ap); buf1[sizeof(buf1)-1] = 0; - write(level, logname, buf1); + char *buf = buf1; + while (true) { + char *end = strchr(buf, '\n'); + if (end) + *end = '\0'; + write(level, logname, buf); + if (!end) + break; + buf = end + 1; + } } void