Module: check_mk
Branch: master
Commit: 36a05ac145c2506d1cc0613f347775f51179d692
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=36a05ac145c250…
Author: Jukka Aro <ja(a)mathias-kettner.de>
Date: Tue Sep 26 08:57:47 2017 +0200
Fix small mishaps in Windows eventlog formatting
* Ensure correct behaviour when trimming null characters at the end of
Vista-formatted event messages by checking that message is non-empty.
Also do this only for eventlogs with vista_api enabled (others should
never have trailing null characters).
* Fix small bug with replacing spaces with underscore in event source
(replacement was done but not used in actual formatted entry).
* Use prefix L for wchar_t characters.
Change-Id: I6e66c9a6ff53789eead45305cf664997065a636c
---
agents/windows/EventLogVista.cc | 10 +++++++++-
agents/windows/build_version | 2 +-
agents/windows/check_mk_agent-64.exe | Bin 1565696 -> 1564160 bytes
agents/windows/check_mk_agent-64.unstripped.exe | Bin 22788184 -> 22765638 bytes
agents/windows/check_mk_agent-64.unversioned.exe | Bin 1565696 -> 1564160 bytes
agents/windows/check_mk_agent.exe | Bin 1548800 -> 1547264 bytes
agents/windows/check_mk_agent.msi | Bin 3388416 -> 3385344 bytes
agents/windows/check_mk_agent.unstripped.exe | Bin 19628575 -> 19613197 bytes
agents/windows/check_mk_agent.unversioned.exe | Bin 1548800 -> 1547264 bytes
agents/windows/crash.exe | Bin 358864 -> 358864 bytes
agents/windows/install_agent-64.exe | Bin 681479 -> 681081 bytes
agents/windows/install_agent.exe | Bin 676294 -> 675979 bytes
agents/windows/nowin.exe | Bin 361000 -> 361000 bytes
agents/windows/plugins/mk_jolokia.exe | Bin 10106814 -> 10106814 bytes
agents/windows/sections/SectionEventlog.cc | 13 +++----------
15 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/agents/windows/EventLogVista.cc b/agents/windows/EventLogVista.cc
index 2a84699..571b978 100644
--- a/agents/windows/EventLogVista.cc
+++ b/agents/windows/EventLogVista.cc
@@ -225,8 +225,16 @@ public:
result = eventData();
}
+ // EvtFormatMessage delivers the formatted message with trailing null
+ // character within the required buffer size! Later, this would cause
+ // the socket output to be cut at the 1st null character, so we need to
+ // trim trailing null away here.
+ while (!result.empty() && result.back() == L'\0') {
+ result.pop_back();
+ }
+
std::replace_if(result.begin(), result.end(),
- [](wchar_t ch) { return ch == '\n' || ch == '\r';
},
+ [](wchar_t ch) { return ch == L'\n' || ch ==
L'\r'; },
' ');
return result;
}
diff --git a/agents/windows/build_version b/agents/windows/build_version
index 004f50e..fa913ef 100644
--- a/agents/windows/build_version
+++ b/agents/windows/build_version
@@ -1 +1 @@
-2932
+2934
diff --git a/agents/windows/check_mk_agent-64.exe b/agents/windows/check_mk_agent-64.exe
index 89f0811..5d74085 100755
Binary files a/agents/windows/check_mk_agent-64.exe and
b/agents/windows/check_mk_agent-64.exe differ
diff --git a/agents/windows/check_mk_agent-64.unstripped.exe
b/agents/windows/check_mk_agent-64.unstripped.exe
index d276630..4b3a495 100755
Binary files a/agents/windows/check_mk_agent-64.unstripped.exe and
b/agents/windows/check_mk_agent-64.unstripped.exe differ
diff --git a/agents/windows/check_mk_agent-64.unversioned.exe
b/agents/windows/check_mk_agent-64.unversioned.exe
index cfacf5d..f5a18d0 100755
Binary files a/agents/windows/check_mk_agent-64.unversioned.exe and
b/agents/windows/check_mk_agent-64.unversioned.exe differ
diff --git a/agents/windows/check_mk_agent.exe b/agents/windows/check_mk_agent.exe
index 49ac323..2761d06 100755
Binary files a/agents/windows/check_mk_agent.exe and b/agents/windows/check_mk_agent.exe
differ
diff --git a/agents/windows/check_mk_agent.msi b/agents/windows/check_mk_agent.msi
index 033e7ce..f28e25d 100755
Binary files a/agents/windows/check_mk_agent.msi and b/agents/windows/check_mk_agent.msi
differ
diff --git a/agents/windows/check_mk_agent.unstripped.exe
b/agents/windows/check_mk_agent.unstripped.exe
index 2bb1a6d..77e684a 100755
Binary files a/agents/windows/check_mk_agent.unstripped.exe and
b/agents/windows/check_mk_agent.unstripped.exe differ
diff --git a/agents/windows/check_mk_agent.unversioned.exe
b/agents/windows/check_mk_agent.unversioned.exe
index 2431dfe..63a2b6b 100755
Binary files a/agents/windows/check_mk_agent.unversioned.exe and
b/agents/windows/check_mk_agent.unversioned.exe differ
diff --git a/agents/windows/crash.exe b/agents/windows/crash.exe
index 5b4e532..eb5a5a7 100755
Binary files a/agents/windows/crash.exe and b/agents/windows/crash.exe differ
diff --git a/agents/windows/install_agent-64.exe b/agents/windows/install_agent-64.exe
index f194649..6a9dae3 100755
Binary files a/agents/windows/install_agent-64.exe and
b/agents/windows/install_agent-64.exe differ
diff --git a/agents/windows/install_agent.exe b/agents/windows/install_agent.exe
index 8223242..f99a168 100755
Binary files a/agents/windows/install_agent.exe and b/agents/windows/install_agent.exe
differ
diff --git a/agents/windows/nowin.exe b/agents/windows/nowin.exe
index c83e8aa..920c5a2 100755
Binary files a/agents/windows/nowin.exe and b/agents/windows/nowin.exe differ
diff --git a/agents/windows/plugins/mk_jolokia.exe
b/agents/windows/plugins/mk_jolokia.exe
index 21327e4..c31890c 100755
Binary files a/agents/windows/plugins/mk_jolokia.exe and
b/agents/windows/plugins/mk_jolokia.exe differ
diff --git a/agents/windows/sections/SectionEventlog.cc
b/agents/windows/sections/SectionEventlog.cc
index 49b2ec7..e3735eb 100644
--- a/agents/windows/sections/SectionEventlog.cc
+++ b/agents/windows/sections/SectionEventlog.cc
@@ -148,17 +148,10 @@ void SectionEventlog::process_eventlog_entry(std::ostream &out,
// source is the application that produced the event
std::string source_name = to_utf8(event.source());
std::replace(source_name.begin(), source_name.end(), ' ', '_');
- auto message = event.message();
- // Nice surprise: EvtFormatMessage (used by Vista API) delivers wstring
- // messages with trailing null character within the allocated wstring size!
- // Later, this causes the socket output to be cut at the 1st null character,
- // so we need to trim trailing null(s) away here.
- while (message.back() == L'\0') {
- message.resize(message.size() - 1);
- }
+
out << type_char << " " << timestamp << "
" << event.eventQualifiers()
- << "." << event.eventId() << " " <<
Utf8(event.source()) << " "
- << Utf8(message) << "\n";
+ << "." << event.eventId() << " " <<
source_name << " "
+ << Utf8(event.message()) << "\n";
}
void SectionEventlog::outputEventlog(std::ostream &out, const char *logname,