Module: check_mk
Branch: master
Commit: 9b99cbd30c17ae1de66a3bf64a75a6089cc95d3c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9b99cbd30c17ae…
Author: Jukka Aro <ja(a)mathias-kettner.de>
Date: Mon Sep 25 09:46:09 2017 +0200
Fix Windows eventlog output with vista_api=yes
The Vista API uses the Win API function EvtFormatMessage that delivers
formatted strings with trailing null characters within the allocated
wstring buffer size. Until the refactoring done in
fc96cd0d661bd51434d252198b574b2dc752a9c6, this did not cause trouble as
the wstring to UTF8 conversion was done using the Win API and 'old' C
strings. The refactoring introduced C++ standard library conversion that
is done on wstring objects instead of C strings. As a consequence, the
trailing null character was taken into the formatted message, later
causing the socket output to be cut at it. The fix is to trim possible
trailing null characters away from the formatted eventlog message.
Change-Id: I2bf5c8093c79e6e7babcc6abb15b91e6d23756d5
---
agents/windows/build_version | 2 +-
agents/windows/check_mk_agent-64.exe | Bin 1565696 -> 1565696 bytes
agents/windows/check_mk_agent-64.unstripped.exe | Bin 22787160 -> 22788184 bytes
agents/windows/check_mk_agent-64.unversioned.exe | Bin 1565696 -> 1565696 bytes
agents/windows/check_mk_agent.exe | Bin 1548800 -> 1548800 bytes
agents/windows/check_mk_agent.msi | Bin 3388416 -> 3388416 bytes
agents/windows/check_mk_agent.unstripped.exe | Bin 19627551 -> 19628575 bytes
agents/windows/check_mk_agent.unversioned.exe | Bin 1548800 -> 1548800 bytes
agents/windows/crash.exe | Bin 358864 -> 358864 bytes
agents/windows/install_agent-64.exe | Bin 681464 -> 681445 bytes
agents/windows/install_agent.exe | Bin 676446 -> 676321 bytes
agents/windows/nowin.exe | Bin 361000 -> 361000 bytes
agents/windows/plugins/mk_jolokia.exe | Bin 10106814 -> 10106814 bytes
agents/windows/sections/SectionEventlog.cc | 11 +++++++++--
14 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/agents/windows/build_version b/agents/windows/build_version
index 9b0efd1..ca6b285 100644
--- a/agents/windows/build_version
+++ b/agents/windows/build_version
@@ -1 +1 @@
-2928
+2930
diff --git a/agents/windows/check_mk_agent-64.exe b/agents/windows/check_mk_agent-64.exe
index a292297..b25ea52 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 dd1dc1b..2d98db5 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 5cf4442..8ffadee 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 822aae6..95e5761 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 2093c92..98f3486 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 a1f58a0..2fba349 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 c8698a4..f33fcf1 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 6069703..0a372ec 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 f2fa75d..b3fa517 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 835a251..f5cfc01 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 de789ac..627f396 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 1245e08..de94659 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 f945824..558422c 100644
--- a/agents/windows/sections/SectionEventlog.cc
+++ b/agents/windows/sections/SectionEventlog.cc
@@ -148,10 +148,17 @@ 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(event.message()) << "\n";
+ << Utf8(message) << "\n";
}
void SectionEventlog::outputEventlog(std::ostream &out, const char *logname,