From c0a3de64fb7a6eeae479615cc6a190e10f474822 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Fri, 29 Sep 2017 14:45:15 +0200 Subject: [PATCH] Fix match(), regex(), cidr_match() behaviour with MatchAll and empty arrays fixes #5634 --- lib/base/scriptutils.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) 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);