From: Michael Friedrich Date: Fri, 29 Sep 2017 12:45:15 +0000 (+0200) Subject: Fix match(), regex(), cidr_match() behaviour with MatchAll and empty arrays X-Git-Tag: v2.8.0~51^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c0a3de64fb7a6eeae479615cc6a190e10f474822;p=icinga2 Fix match(), regex(), cidr_match() behaviour with MatchAll and empty arrays fixes #5634 --- diff --git a/lib/base/scriptutils.cpp b/lib/base/scriptutils.cpp index 7335c58fc..f71b1b869 100644 --- a/lib/base/scriptutils.cpp +++ b/lib/base/scriptutils.cpp @@ -128,6 +128,9 @@ bool ScriptUtils::Regex(const std::vector& 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& 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& args) ips->Add(argIps); } + if (ips->GetLength() == 0) + return false; + ObjectLock olock(ips); for (const String& ip : ips) { bool res = Utility::CidrMatch(pattern, ip);