Module: check_mk
Branch: master
Commit: 37279d6eec797fdc0b0e9ee56d832e15820c8ee2
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=37279d6eec797f…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Wed Oct 30 13:53:50 2013 +0100
table statehist: fixed SIGSEGV chance on larger queries (strtok...)
---
ChangeLog | 3 ++-
livestatus/src/TableStateHistory.cc | 14 ++++++++------
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 24bd7f8..c730666 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -123,8 +123,9 @@
* Removed "livecheck". It never was really stable. Nagios4 has something
similar built in. And also the Check_MK Micro Core.
* table statehist: no longer computes an unmonitored state for hosts and
- services on certain instances.
+ services on certain instances.
(showed up as no hosts/services in the multisite gui)
+ * table statehist: fixed SIGSEGV chance on larger queries
1.2.3i4:
Core:
diff --git a/livestatus/src/TableStateHistory.cc b/livestatus/src/TableStateHistory.cc
index ac95135..e35088b 100644
--- a/livestatus/src/TableStateHistory.cc
+++ b/livestatus/src/TableStateHistory.cc
@@ -567,10 +567,11 @@ void TableStateHistory::answerQuery(Query *query)
}
case TIMEPERIOD_TRANSITION:
{
+ char *save_ptr;
char *buffer = strdup(entry->_options);
- char *tp_name = strtok(buffer, ";");
- strtok(NULL, ";");
- char *tp_state = strtok(NULL, ";");
+ char *tp_name = strtok_r(buffer, ";", &save_ptr);
+ strtok_r(NULL, ";", &save_ptr);
+ char *tp_state = strtok_r(NULL, ";", &save_ptr);
_notification_periods[tp_name] = atoi(tp_state);
state_info_t::iterator it_hst = state_info.begin();
@@ -768,10 +769,11 @@ inline int TableStateHistory::updateHostServiceState(Query *query,
const LogEntr
}
case TIMEPERIOD_TRANSITION:
{
+ char *save_ptr;
char *buffer = strdup(entry->_options);
- char *tp_name = strtok(buffer, ";");
- strtok(NULL, ";");
- char *tp_state = strtok(NULL, ";");
+ char *tp_name = strtok_r(buffer, ";", &save_ptr);
+ strtok_r(NULL, ";", &save_ptr);
+ char *tp_state = strtok_r(NULL, ";", &save_ptr);
// if no _host pointer is available the initial status of _in_notification_period
(1) never changes
if (hs_state->_host && !strcmp(tp_name,
hs_state->_notification_period)) {