Module: check_mk
Branch: master
Commit: cd7aa28d9bd6eddbffa9981d7ee4de417a7fdb3b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=cd7aa28d9bd6ed…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Tue Apr 15 11:08:29 2014 +0200
FIX table statehist: no longer crashes on TIMEPERIOD TRANSITION entries with an invalid
syntax
The livestatus table could crash incomplete TIMEPERIOD TRANSITION logentries which where
caused by a maximum line length. <br><br>
<tt>Working:</tt><br>
[1391727600] TIMEPERIOD TRANSITION: good_transition;0;1<br>
<tt>Caused crash:</tt><br>
[1391727600] TIMEPERIOD TRANSITION: this_timeperiod_transition_name_is_way_too_lo
---
.werks/831 | 15 +++++++++++++++
ChangeLog | 1 +
livestatus/src/TableStateHistory.cc | 9 +++++++++
3 files changed, 25 insertions(+)
diff --git a/.werks/831 b/.werks/831
new file mode 100644
index 0000000..5d44271
--- /dev/null
+++ b/.werks/831
@@ -0,0 +1,15 @@
+Title: table statehist: no longer crashes on TIMEPERIOD TRANSITION entries with an
invalid syntax
+Level: 1
+Component: livestatus
+Class: fix
+State: unknown
+Version: 1.2.5i3
+Date: 1397552565
+
+The livestatus table could crash incomplete TIMEPERIOD TRANSITION logentries which where
+caused by a maximum line length. <br><br>
+<tt>Working:</tt><br>
+[1391727600] TIMEPERIOD TRANSITION: good_transition;0;1<br>
+<tt>Caused crash:</tt><br>
+[1391727600] TIMEPERIOD TRANSITION: this_timeperiod_transition_name_is_way_too_lo
+
diff --git a/ChangeLog b/ChangeLog
index 5f0089d..9a7f3bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -63,6 +63,7 @@
Livestatus:
* 0747 FIX: livestatus table hostsbygroup: fixed bug with group_authorization
strict...
+ * 0831 FIX: table statehist: no longer crashes on TIMEPERIOD TRANSITION entries with
an invalid syntax...
HW/SW-Inventory:
* 0886 FIX: Fix exception on non-UTF-8 encoded characters in software list
diff --git a/livestatus/src/TableStateHistory.cc b/livestatus/src/TableStateHistory.cc
index 39d1ab7..5d4ac39 100644
--- a/livestatus/src/TableStateHistory.cc
+++ b/livestatus/src/TableStateHistory.cc
@@ -611,6 +611,15 @@ void TableStateHistory::answerQuery(Query *query)
char *tp_name = strtok_r(buffer, ";", &save_ptr);
strtok_r(NULL, ";", &save_ptr);
char *tp_state = strtok_r(NULL, ";", &save_ptr);
+ if (tp_state)
+ tp_state = strtok_r(NULL, ";", &save_ptr);
+
+ if (tp_state == NULL) {
+ // This line is broken...
+ logger(LOG_WARNING, "Error: Invalid syntax of TIMEPERIOD TRANSITION:
%s", entry->_complete);
+ free(buffer);
+ break;
+ }
_notification_periods[tp_name] = atoi(tp_state);
state_info_t::iterator it_hst = state_info.begin();