From decd5578bcf848791dfbd8640027964989ee3ebc Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Thu, 16 Nov 2017 13:52:28 +0200 Subject: [PATCH] MXS-1525 Check exact match first when checking host Given a rule like ... users %@127.0.0.1 match any rules ... the code started with %@127.0.0.%, which meant that the exact match rule would be missed. --- server/modules/filter/dbfwfilter/dbfwfilter.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/server/modules/filter/dbfwfilter/dbfwfilter.cc b/server/modules/filter/dbfwfilter/dbfwfilter.cc index f87e09177..233e062ef 100644 --- a/server/modules/filter/dbfwfilter/dbfwfilter.cc +++ b/server/modules/filter/dbfwfilter/dbfwfilter.cc @@ -1272,11 +1272,16 @@ static SUser find_user_data(const UserMap& users, std::string name, std::string if (it == users.end()) { snprintf(nameaddr, sizeof(nameaddr), "%%@%s", remote.c_str()); - ip_start = strchr(nameaddr, '@') + 1; + it = users.find(nameaddr); - while (it == users.end() && next_ip_class(ip_start)) + if (it == users.end()) { - it = users.find(nameaddr); + ip_start = strchr(nameaddr, '@') + 1; + + while (it == users.end() && next_ip_class(ip_start)) + { + it = users.find(nameaddr); + } } } }