Fix nullptr deref in cluster events

This commit is contained in:
Noah Hilverling 2018-01-31 10:17:49 +01:00 committed by Jean Flach
parent 3ba5090867
commit 71c420d501
3 changed files with 5 additions and 37 deletions

View File

@ -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)

View File

@ -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<X509> cert;

View File

@ -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();