From 88bf3b916591f69f25c7c886e6d0632bfb8ea567 Mon Sep 17 00:00:00 2001 From: schmidt Date: Fri, 20 Nov 2009 18:14:36 +0000 Subject: ChangeLogTag:Thu --- ACE/ace/Log_Msg_NT_Event_Log.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'ACE/ace/Log_Msg_NT_Event_Log.cpp') diff --git a/ACE/ace/Log_Msg_NT_Event_Log.cpp b/ACE/ace/Log_Msg_NT_Event_Log.cpp index e22170c01dc..4883dee9409 100644 --- a/ACE/ace/Log_Msg_NT_Event_Log.cpp +++ b/ACE/ace/Log_Msg_NT_Event_Log.cpp @@ -106,11 +106,16 @@ ACE_Log_Msg_NT_Event_Log::log (ACE_Log_Record &log_record) // CR-LF. Newline characters on their own do not appear correctly in // the event viewer. We allow for a doubling in the size of the msg // data for the worst case of all newlines. - const ACE_TCHAR* src_msg_data = log_record.msg_data (); - ACE_TCHAR msg_data [ACE_Log_Record::MAXLOGMSGLEN * 2]; + const ACE_TCHAR *src_msg_data = log_record.msg_data (); + ACE_TCHAR msg_data [(ACE_Log_Record::MAXLOGMSGLEN * 2) + 1]; + size_t maxlen = ACE_Log_Record::MAXLOGMSGLEN; + if (ACE_Log_Record::MAXLOGMSGLEN > log_record.msg_data_len ()) + maxlen = log_record.msg_data_len (); + + size_t end = 0; for (size_t i = 0, j = 0; - i < log_record.msg_data_len (); + i < maxlen; ++i) { if (src_msg_data[i] == '\n') @@ -120,7 +125,10 @@ ACE_Log_Msg_NT_Event_Log::log (ACE_Log_Record &log_record) } else msg_data[j++] = src_msg_data[i]; + + end = j; } + msg_data[end] = '\0'; // Map the ACE log record type to an event log type. WORD event_type; -- cgit v1.2.1