[icinga-checkins] icinga.org: icinga2/master: Fix external commands comments crashing icinga

git at icinga.org git at icinga.org
Tue May 17 11:44:09 CEST 2016


Module: icinga2
Branch: master
Commit: 0e70165bc9403395f57c453a05a40ae3f7bbf4d3
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=0e70165bc9403395f57c453a05a40ae3f7bbf4d3

Author: Jean Flach <jean-marcel.flach at netways.de>
Date:   Mon Apr 25 16:52:09 2016 +0200

Fix external commands comments crashing icinga

Now an exception will be thrown when AddSvcComment or AddHostComment are
run with and empty Author or comment

fixes #11112

---

 lib/icinga/externalcommandprocessor.cpp |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/icinga/externalcommandprocessor.cpp b/lib/icinga/externalcommandprocessor.cpp
index b9f0479..2bb2258 100644
--- a/lib/icinga/externalcommandprocessor.cpp
+++ b/lib/icinga/externalcommandprocessor.cpp
@@ -1228,6 +1228,9 @@ void ExternalCommandProcessor::AddHostComment(double, const std::vector<String>&
 	if (!host)
 		BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot add host comment for non-existent host '" + arguments[0] + "'"));
 
+	if (arguments[2].IsEmpty() || arguments[3].IsEmpty())
+		BOOST_THROW_EXCEPTION(std::invalid_argument("Author and comment may not be empty"));
+
 	Log(LogNotice, "ExternalCommandProcessor")
 	    << "Creating comment for host " << host->GetName();
 	(void) Comment::AddComment(host, CommentUser, arguments[2], arguments[3], 0);
@@ -1249,6 +1252,9 @@ void ExternalCommandProcessor::AddSvcComment(double, const std::vector<String>&
 	if (!service)
 		BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot add service comment for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
 
+	if (arguments[3].IsEmpty() || arguments[4].IsEmpty())
+		BOOST_THROW_EXCEPTION(std::invalid_argument("Author and comment may not be empty"));
+
 	Log(LogNotice, "ExternalCommandProcessor")
 	    << "Creating comment for service " << service->GetName();
 	(void) Comment::AddComment(service, CommentUser, arguments[3], arguments[4], 0);



More information about the icinga-checkins mailing list