[icinga-checkins] icinga.org: icinga2/support/2.5: Fix crash in CheckResult cluster handlers

git at icinga.org git at icinga.org
Thu Nov 17 13:51:08 CET 2016


Module: icinga2
Branch: support/2.5
Commit: 67ebcc2ed0217533abcf2d75c1f880f08fdef552
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=67ebcc2ed0217533abcf2d75c1f880f08fdef552

Author: Michael Friedrich <michael.friedrich at icinga.com>
Date:   Thu Nov 10 20:00:38 2016 +0100

Fix crash in CheckResult cluster handlers

fixes #13151

---

 lib/icinga/clusterevents.cpp |   76 +++++++++++++++++++++++++++++++-----------
 1 file changed, 56 insertions(+), 20 deletions(-)

diff --git a/lib/icinga/clusterevents.cpp b/lib/icinga/clusterevents.cpp
index 1898cd8..e0cbe9f 100644
--- a/lib/icinga/clusterevents.cpp
+++ b/lib/icinga/clusterevents.cpp
@@ -126,13 +126,22 @@ Value ClusterEvents::CheckResultAPIHandler(const MessageOrigin::Ptr& origin, con
 	if (!params)
 		return Empty;
 
-	CheckResult::Ptr cr = new CheckResult();
+	CheckResult::Ptr cr;
+	Array::Ptr vperf;
 
-	Dictionary::Ptr vcr = params->Get("cr");
-	Array::Ptr vperf = vcr->Get("performance_data");
-	vcr->Remove("performance_data");
+	if (params->Contains("cr")) {
+		cr = new CheckResult();
+		Dictionary::Ptr vcr = params->Get("cr");
 
-	Deserialize(cr, params->Get("cr"), true);
+		if (vcr && vcr->Contains("performance_data")) {
+			vperf = vcr->Get("performance_data");
+
+			if (vperf)
+				vcr->Remove("performance_data");
+
+			Deserialize(cr, vcr, true);
+		}
+	}
 
 	Array::Ptr rperf = new Array();
 
@@ -826,13 +835,22 @@ Value ClusterEvents::SendNotificationsAPIHandler(const MessageOrigin::Ptr& origi
 		return Empty;
 	}
 
-	CheckResult::Ptr cr = new CheckResult();
+	CheckResult::Ptr cr;
+	Array::Ptr vperf;
 
-	Dictionary::Ptr vcr = params->Get("cr");
-	Array::Ptr vperf = vcr->Get("performance_data");
-	vcr->Remove("performance_data");
+	if (params->Contains("cr")) {
+		cr = new CheckResult();
+		Dictionary::Ptr vcr = params->Get("cr");
 
-	Deserialize(cr, params->Get("cr"), true);
+		if (vcr && vcr->Contains("performance_data")) {
+			vperf = vcr->Get("performance_data");
+
+			if (vperf)
+				vcr->Remove("performance_data");
+
+			Deserialize(cr, vcr, true);
+		}
+	}
 
 	NotificationType type = static_cast<NotificationType>(static_cast<int>(params->Get("type")));
 	String author = params->Get("author");
@@ -910,13 +928,22 @@ Value ClusterEvents::NotificationSentUserAPIHandler(const MessageOrigin::Ptr& or
 		return Empty;
 	}
 
-	CheckResult::Ptr cr = new CheckResult();
+	CheckResult::Ptr cr;
+	Array::Ptr vperf;
 
-	Dictionary::Ptr vcr = params->Get("cr");
-	Array::Ptr vperf = vcr->Get("performance_data");
-	vcr->Remove("performance_data");
+	if (params->Contains("cr")) {
+		cr = new CheckResult();
+		Dictionary::Ptr vcr = params->Get("cr");
 
-	Deserialize(cr, params->Get("cr"), true);
+		if (vcr && vcr->Contains("performance_data")) {
+			vperf = vcr->Get("performance_data");
+
+			if (vperf)
+				vcr->Remove("performance_data");
+
+			Deserialize(cr, vcr, true);
+		}
+	}
 
 	NotificationType type = static_cast<NotificationType>(static_cast<int>(params->Get("type")));
 	String author = params->Get("author");
@@ -1016,13 +1043,22 @@ Value ClusterEvents::NotificationSentToAllUsersAPIHandler(const MessageOrigin::P
 		return Empty;
 	}
 
-	CheckResult::Ptr cr = new CheckResult();
+	CheckResult::Ptr cr;
+	Array::Ptr vperf;
 
-	Dictionary::Ptr vcr = params->Get("cr");
-	Array::Ptr vperf = vcr->Get("performance_data");
-	vcr->Remove("performance_data");
+	if (params->Contains("cr")) {
+		cr = new CheckResult();
+		Dictionary::Ptr vcr = params->Get("cr");
 
-	Deserialize(cr, params->Get("cr"), true);
+		if (vcr && vcr->Contains("performance_data")) {
+			vperf = vcr->Get("performance_data");
+
+			if (vperf)
+				vcr->Remove("performance_data");
+
+			Deserialize(cr, vcr, true);
+		}
+	}
 
 	NotificationType type = static_cast<NotificationType>(static_cast<int>(params->Get("type")));
 	String author = params->Get("author");



More information about the icinga-checkins mailing list