[icinga-checkins] icinga.org: icinga2/next: Fix Livestatus queries where the second operand is omitted

git at icinga.org git at icinga.org
Tue Jun 24 12:52:42 CEST 2014


Module: icinga2
Branch: next
Commit: 6bf47fd221110fc10231310806878146e2aaf5fd
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=6bf47fd221110fc10231310806878146e2aaf5fd

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Tue Jun 24 12:51:56 2014 +0200

Fix Livestatus queries where the second operand is omitted

fixes #6494

---

 components/livestatus/livestatusquery.cpp |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/components/livestatus/livestatusquery.cpp b/components/livestatus/livestatusquery.cpp
index 698163a..9bb4e59 100644
--- a/components/livestatus/livestatusquery.cpp
+++ b/components/livestatus/livestatusquery.cpp
@@ -293,9 +293,14 @@ Filter::Ptr LivestatusQuery::ParseFilter(const String& params, unsigned long& fr
 	for (int i = 0; i < 2; i++) {
 		sp_index = temp_buffer.FindFirstOf(" ");
 
-		/* 'attr op' or 'attr op val' is valid */
-		if (i < 1 && sp_index == String::NPos)
-			BOOST_THROW_EXCEPTION(std::runtime_error("Livestatus filter '" + params + "' does not contain all required fields."));
+		/* check if this is the last argument */
+		if (sp_index == String::NPos) {
+			/* 'attr op' or 'attr op val' is valid */
+			if (i < 1)
+				BOOST_THROW_EXCEPTION(std::runtime_error("Livestatus filter '" + params + "' does not contain all required fields."));
+
+			break;
+		}
 
 		tokens.push_back(temp_buffer.SubStr(0, sp_index));
 		temp_buffer = temp_buffer.SubStr(sp_index + 1);



More information about the icinga-checkins mailing list