]> granicus.if.org Git - icinga2/commitdiff
Fix Livestatus queries where the second operand is omitted
authorGunnar Beutner <gunnar.beutner@netways.de>
Tue, 24 Jun 2014 10:51:56 +0000 (12:51 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 24 Jun 2014 10:51:56 +0000 (12:51 +0200)
fixes #6494

components/livestatus/livestatusquery.cpp

index 698163a25296b53861191c7de71536c344767eb7..9bb4e5982d7b8e233661eaf9d9509e2903bc57e7 100644 (file)
@@ -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);