]> granicus.if.org Git - icinga2/commitdiff
Fix match(), regex(), cidr_match() behaviour with MatchAll and empty arrays 5635/head
authorMichael Friedrich <michael.friedrich@icinga.com>
Fri, 29 Sep 2017 12:45:15 +0000 (14:45 +0200)
committerMichael Friedrich <michael.friedrich@icinga.com>
Fri, 29 Sep 2017 12:45:15 +0000 (14:45 +0200)
fixes #5634

lib/base/scriptutils.cpp

index 7335c58fcc79a49989f1a24414fc4eefaa288a25..f71b1b8699bcf2c11272067856c43f103e0d111d 100644 (file)
@@ -128,6 +128,9 @@ bool ScriptUtils::Regex(const std::vector<Value>& args)
                texts->Add(argTexts);
        }
 
+       if (texts->GetLength() == 0)
+               return false;
+
        ObjectLock olock(texts);
        for (const String& text : texts) {
                bool res = false;
@@ -171,6 +174,9 @@ bool ScriptUtils::Match(const std::vector<Value>& args)
                texts->Add(argTexts);
        }
 
+       if (texts->GetLength() == 0)
+               return false;
+
        ObjectLock olock(texts);
        for (const String& text : texts) {
                bool res = Utility::Match(pattern, text);
@@ -207,6 +213,9 @@ bool ScriptUtils::CidrMatch(const std::vector<Value>& args)
                ips->Add(argIps);
        }
 
+       if (ips->GetLength() == 0)
+               return false;
+
        ObjectLock olock(ips);
        for (const String& ip : ips) {
                bool res = Utility::CidrMatch(pattern, ip);