Module: check_mk
Branch: master
Commit: 2a24c3696daf1944b69121f29da72eca68ab0318
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2a24c3696daf19…
Author: Jukka Aro <ja(a)mathias-kettner.de>
Date: Thu Jan 18 11:33:32 2018 +0100
5689 FIX Newline in mrpe include file crashed Windows agent
A newline character in a file included through the mrpe configuration
option <tt>include</tt> (see Werk #266) put Windows agent into an
eternal loop.
Change-Id: I28018d8a9f88c96e0013c62895374e32f573342c
---
.werks/5689 | 15 +++++++++++++++
agents/windows/build_version | 2 +-
agents/windows/sections/SectionMRPE.cc | 8 +-------
3 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/.werks/5689 b/.werks/5689
new file mode 100644
index 0000000..5154085
--- /dev/null
+++ b/.werks/5689
@@ -0,0 +1,15 @@
+Title: Newline in mrpe include file crashed Windows agent
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i3
+Date: 1516267515
+Class: fix
+
+A newline character in a file included through the mrpe configuration
+option <tt>include</tt> (see Werk #266) put Windows agent into an
+eternal loop.
+
+
+
diff --git a/agents/windows/build_version b/agents/windows/build_version
index 4ac94f0..27be29d 100644
--- a/agents/windows/build_version
+++ b/agents/windows/build_version
@@ -1 +1 @@
-3068
+3070
diff --git a/agents/windows/sections/SectionMRPE.cc
b/agents/windows/sections/SectionMRPE.cc
index 0fcd1e4..184400a 100644
--- a/agents/windows/sections/SectionMRPE.cc
+++ b/agents/windows/sections/SectionMRPE.cc
@@ -52,14 +52,8 @@ void SectionMRPE::updateIncludes() {
}
lineno = 0;
- while (!feof(file)) {
+ while (fgets(line, sizeof(line), file) != nullptr) {
lineno++;
- if (!fgets(line, sizeof(line), file)) {
- printf("intern clse\n");
- fclose(file);
- continue;
- }
-
char *l = strip(line);
if (l[0] == 0 || l[0] == '#' || l[0] == ';')
continue; // skip empty lines and comments