From: Noah Hilverling Date: Wed, 31 Jan 2018 09:17:49 +0000 (+0100) Subject: Fix nullptr deref in cluster events X-Git-Tag: v2.8.2~44 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=71c420d5014cd84e67acd1504945ee542d48cc39;p=icinga2 Fix nullptr deref in cluster events --- diff --git a/lib/icinga/clusterevents.cpp b/lib/icinga/clusterevents.cpp index 57b4691e1..a9d8ba825 100644 --- a/lib/icinga/clusterevents.cpp +++ b/lib/icinga/clusterevents.cpp @@ -114,9 +114,6 @@ Value ClusterEvents::CheckResultAPIHandler(const MessageOrigin::Ptr& origin, con return Empty; } - if (!params) - return Empty; - CheckResult::Ptr cr; Array::Ptr vperf; @@ -220,9 +217,6 @@ Value ClusterEvents::NextCheckChangedAPIHandler(const MessageOrigin::Ptr& origin return Empty; } - if (!params) - return Empty; - Host::Ptr host = Host::GetByName(params->Get("host")); if (!host) @@ -284,9 +278,6 @@ Value ClusterEvents::NextNotificationChangedAPIHandler(const MessageOrigin::Ptr& return Empty; } - if (!params) - return Empty; - Notification::Ptr notification = Notification::GetByName(params->Get("notification")); if (!notification) @@ -344,9 +335,6 @@ Value ClusterEvents::ForceNextCheckChangedAPIHandler(const MessageOrigin::Ptr& o return Empty; } - if (!params) - return Empty; - Host::Ptr host = Host::GetByName(params->Get("host")); if (!host) @@ -409,9 +397,6 @@ Value ClusterEvents::ForceNextNotificationChangedAPIHandler(const MessageOrigin: return Empty; } - if (!params) - return Empty; - Host::Ptr host = Host::GetByName(params->Get("host")); if (!host) @@ -480,9 +465,6 @@ Value ClusterEvents::AcknowledgementSetAPIHandler(const MessageOrigin::Ptr& orig return Empty; } - if (!params) - return Empty; - Host::Ptr host = Host::GetByName(params->Get("host")); if (!host) @@ -546,9 +528,6 @@ Value ClusterEvents::AcknowledgementClearedAPIHandler(const MessageOrigin::Ptr& return Empty; } - if (!params) - return Empty; - Host::Ptr host = Host::GetByName(params->Get("host")); if (!host) @@ -717,9 +696,6 @@ Value ClusterEvents::SendNotificationsAPIHandler(const MessageOrigin::Ptr& origi return Empty; } - if (!params) - return Empty; - Host::Ptr host = Host::GetByName(params->Get("host")); if (!host) @@ -811,9 +787,6 @@ Value ClusterEvents::NotificationSentUserAPIHandler(const MessageOrigin::Ptr& or return Empty; } - if (!params) - return Empty; - Host::Ptr host = Host::GetByName(params->Get("host")); if (!host) @@ -927,9 +900,6 @@ Value ClusterEvents::NotificationSentToAllUsersAPIHandler(const MessageOrigin::P return Empty; } - if (!params) - return Empty; - Host::Ptr host = Host::GetByName(params->Get("host")); if (!host) diff --git a/lib/remote/jsonrpcconnection-pki.cpp b/lib/remote/jsonrpcconnection-pki.cpp index 048d6c1c1..5a76524e2 100644 --- a/lib/remote/jsonrpcconnection-pki.cpp +++ b/lib/remote/jsonrpcconnection-pki.cpp @@ -40,9 +40,6 @@ REGISTER_APIFUNCTION(UpdateCertificate, pki, &UpdateCertificateHandler); Value RequestCertificateHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params) { - if (!params) - return Empty; - String certText = params->Get("cert_request"); boost::shared_ptr cert; diff --git a/lib/remote/jsonrpcconnection.cpp b/lib/remote/jsonrpcconnection.cpp index e6cd9a3c8..0be3fb46e 100644 --- a/lib/remote/jsonrpcconnection.cpp +++ b/lib/remote/jsonrpcconnection.cpp @@ -212,7 +212,11 @@ void JsonRpcConnection::MessageHandler(const String& jsonString) Log(LogNotice, "JsonRpcConnection") << "Call to non-existent function '" << method << "' from endpoint '" << m_Identity << "'."; } else { - resultMessage->Set("result", afunc->Invoke(origin, message->Get("params"))); + Dictionary::Ptr params = message->Get("params"); + if (params) + resultMessage->Set("result", afunc->Invoke(origin, params)); + else + resultMessage->Set("result", Empty); } } catch (const std::exception& ex) { /* TODO: Add a user readable error message for the remote caller */ @@ -274,9 +278,6 @@ void JsonRpcConnection::DataAvailableHandler(void) Value SetLogPositionHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params) { - if (!params) - return Empty; - double log_position = params->Get("log_position"); Endpoint::Ptr endpoint = origin->FromClient->GetEndpoint();