From d96fbd1bce1a8148e276c8f98d5f3cb8b23dce8a Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 5 Jul 2016 13:00:54 +0200 Subject: [PATCH 1/2] Initialise WLog PrefixString for each message type. --- winpr/libwinpr/utils/wlog/CallbackAppender.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/winpr/libwinpr/utils/wlog/CallbackAppender.c b/winpr/libwinpr/utils/wlog/CallbackAppender.c index 8a1719ff4..aec3865b9 100644 --- a/winpr/libwinpr/utils/wlog/CallbackAppender.c +++ b/winpr/libwinpr/utils/wlog/CallbackAppender.c @@ -49,6 +49,7 @@ static BOOL WLog_CallbackAppender_WriteMessage(wLog* log, wLogAppender* appender if (!appender) return FALSE; + message->PrefixString = prefix; WLog_Layout_GetMessagePrefix(log, appender->Layout, message); @@ -62,11 +63,15 @@ static BOOL WLog_CallbackAppender_WriteMessage(wLog* log, wLogAppender* appender static BOOL WLog_CallbackAppender_WriteDataMessage(wLog* log, wLogAppender* appender, wLogMessage* message) { - + char prefix[WLOG_MAX_PREFIX_SIZE]; wLogCallbackAppender* callbackAppender; + if (!appender) return FALSE; + message->PrefixString = prefix; + WLog_Layout_GetMessagePrefix(log, appender->Layout, message); + callbackAppender = (wLogCallbackAppender *)appender; if (callbackAppender->callbacks && callbackAppender->callbacks->data) return callbackAppender->callbacks->data(message); @@ -76,10 +81,15 @@ static BOOL WLog_CallbackAppender_WriteDataMessage(wLog* log, wLogAppender* appe static BOOL WLog_CallbackAppender_WriteImageMessage(wLog* log, wLogAppender* appender, wLogMessage* message) { + char prefix[WLOG_MAX_PREFIX_SIZE]; wLogCallbackAppender* callbackAppender; + if (!appender) return FALSE; + message->PrefixString = prefix; + WLog_Layout_GetMessagePrefix(log, appender->Layout, message); + callbackAppender = (wLogCallbackAppender *)appender; if (callbackAppender->callbacks && callbackAppender->callbacks->image) return callbackAppender->callbacks->image(message); @@ -89,10 +99,15 @@ static BOOL WLog_CallbackAppender_WriteImageMessage(wLog* log, wLogAppender* app static BOOL WLog_CallbackAppender_WritePacketMessage(wLog* log, wLogAppender* appender, wLogMessage* message) { + char prefix[WLOG_MAX_PREFIX_SIZE]; wLogCallbackAppender* callbackAppender; + if (!appender) return FALSE; + message->PrefixString = prefix; + WLog_Layout_GetMessagePrefix(log, appender->Layout, message); + callbackAppender = (wLogCallbackAppender *)appender; if (callbackAppender->callbacks && callbackAppender->callbacks->package) return callbackAppender->callbacks->package(message); From 2ceb38a1c8a3080f32e65916080742b697e020b8 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 5 Jul 2016 13:22:28 +0200 Subject: [PATCH 2/2] Proper wLogMessage initialisation. --- winpr/include/winpr/wlog.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/winpr/include/winpr/wlog.h b/winpr/include/winpr/wlog.h index fc8a67703..f8e1480c9 100644 --- a/winpr/include/winpr/wlog.h +++ b/winpr/include/winpr/wlog.h @@ -111,6 +111,7 @@ WINPR_API BOOL WLog_PrintMessageVA(wLog* log, wLogMessage* message, va_list args do { \ if (_log && _log_level >= WLog_GetLogLevel(_log)) { \ wLogMessage _log_message; \ + memset(&_log_message, 0, sizeof(_log_message)); \ _log_message.Type = WLOG_MESSAGE_TEXT; \ _log_message.Level = _log_level; \ _log_message.FormatString = _fmt; \ @@ -125,6 +126,7 @@ WINPR_API BOOL WLog_PrintMessageVA(wLog* log, wLogMessage* message, va_list args do { \ if (_log && _log_level >= WLog_GetLogLevel(_log)) { \ wLogMessage _log_message; \ + memset(&_log_message, 0, sizeof(_log_message)); \ _log_message.Type = WLOG_MESSAGE_TEXT; \ _log_message.Level = _log_level; \ _log_message.FormatString = _fmt; \ @@ -139,6 +141,7 @@ WINPR_API BOOL WLog_PrintMessageVA(wLog* log, wLogMessage* message, va_list args do { \ if (_log && _log_level >= WLog_GetLogLevel(_log)) { \ wLogMessage _log_message; \ + memset(&_log_message, 0, sizeof(_log_message)); \ _log_message.Type = WLOG_MESSAGE_DATA; \ _log_message.Level = _log_level; \ _log_message.FormatString = NULL; \ @@ -153,6 +156,7 @@ WINPR_API BOOL WLog_PrintMessageVA(wLog* log, wLogMessage* message, va_list args do { \ if (_log && _log_level >= WLog_GetLogLevel(_log)) { \ wLogMessage _log_message; \ + memset(&_log_message, 0, sizeof(_log_message)); \ _log_message.Type = WLOG_MESSAGE_IMAGE; \ _log_message.Level = _log_level; \ _log_message.FormatString = NULL; \ @@ -167,6 +171,7 @@ WINPR_API BOOL WLog_PrintMessageVA(wLog* log, wLogMessage* message, va_list args do { \ if (_log && _log_level >= WLog_GetLogLevel(_log)) { \ wLogMessage _log_message; \ + memset(&_log_message, 0, sizeof(_log_message)); \ _log_message.Type = WLOG_MESSAGE_PACKET; \ _log_message.Level = _log_level; \ _log_message.FormatString = NULL; \