Module: check_mk
Branch: master
Commit: 79861d5e53542f489f5b55f69ea48e40760dba0b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=79861d5e53542f…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Oct 5 11:49:27 2015 +0200
#2648 FIX Fix crash of core in case of case of certain garbled log lines
A query to the table <tt>log</tt> could crash the core when certain garbled
lines
in the history file are being seen. This has been fixed.
---
.werks/2648 | 11 +++++++++++
ChangeLog | 1 +
livestatus/src/LogEntry.cc | 6 ++++++
3 files changed, 18 insertions(+)
diff --git a/.werks/2648 b/.werks/2648
new file mode 100644
index 0000000..b08da49
--- /dev/null
+++ b/.werks/2648
@@ -0,0 +1,11 @@
+Title: Fix crash of core in case of case of certain garbled log lines
+Level: 1
+Component: livestatus
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i3
+Date: 1444038366
+
+A query to the table <tt>log</tt> could crash the core when certain garbled
lines
+in the history file are being seen. This has been fixed.
diff --git a/ChangeLog b/ChangeLog
index 0c5702e..f1f3b48 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -333,6 +333,7 @@
* 2493 FIX: Fixed wrong JSON format when using stats queries together with header
columns...
* 2542 FIX: Fix segmentation fault when filtering for service columns in log
table...
* 2581 FIX: Fix crashing Nagios core in rare case when excessive commands are being
executed...
+ * 2648 FIX: Fix crash of core in case of case of certain garbled log lines...
HW/SW-Inventory:
* 2128 mk_inventory.vbs: inventory plugin for Windows now available as vbs script...
diff --git a/livestatus/src/LogEntry.cc b/livestatus/src/LogEntry.cc
index 5634b8e..015decf 100644
--- a/livestatus/src/LogEntry.cc
+++ b/livestatus/src/LogEntry.cc
@@ -405,6 +405,9 @@ inline bool LogEntry::handleProgrammEntry()
inline int LogEntry::serviceStateToInt(char *s)
{
+ if (!s)
+ return 3; // can happen at garbled log line
+
char *last = s + strlen(s) - 1;
if (*last == ')')
last--;
@@ -423,6 +426,9 @@ inline int LogEntry::serviceStateToInt(char *s)
inline int LogEntry::hostStateToInt(char *s)
{
+ if (!s)
+ return 2; // can happen at garbled log line
+
char *last = s + strlen(s) - 1;
if (*last == ')') // handle CUSTOM (UP) and DOWNTIMESTOPPED (DOWN)
last--;