From 46c2c4627340c0c107ce31b95806ab77c157d3a6 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 1 Nov 2018 16:04:30 +0100 Subject: [PATCH] Handle line breaks in log messages --- common/rfb/Logger.cxx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 -- 2.39.5