summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2024-10-04 14:57:09 +0100
committerSadie Powell <sadie@witchery.services>2024-10-04 14:57:09 +0100
commitcdf356ed33a56926412c1d063b614f6b7f9f72d8 (patch)
tree36e60e148d1a069450494f63bc332544e391469f
parent7d268bb4cabb4cb7fc73fc8e9ecc8ae560b71643 (diff)
Fix validating named extbans on UnrealIRCd.
-rw-r--r--modules/protocol/unrealircd.cpp43
1 files changed, 27 insertions, 16 deletions
diff --git a/modules/protocol/unrealircd.cpp b/modules/protocol/unrealircd.cpp
index bea0e727a..6434b4007 100644
--- a/modules/protocol/unrealircd.cpp
+++ b/modules/protocol/unrealircd.cpp
@@ -14,7 +14,31 @@
#include "modules/sasl.h"
typedef Anope::map<Anope::string> ModData;
-static Anope::string UplinkSID;
+
+namespace
+{
+ Anope::string UplinkSID;
+
+ bool IsExtBan(const Anope::string &str, Anope::string &name, Anope::string &value)
+ {
+ if (str[0] != '~')
+ {
+ Log() << "missing prefix: " << str;
+ return false;
+ }
+
+ auto endpos = str.find_first_not_of("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 1);
+ if (endpos == Anope::string::npos || str[endpos] != ':' || endpos+1 == str.length())
+ {
+ Log() << "wrong format: " << str;
+ return false;
+ }
+
+ name = str.substr(1, endpos - 1);
+ value = str.substr(endpos + 1);
+ return true;
+ }
+}
class UnrealIRCdProto final
: public IRCDProto
@@ -346,7 +370,8 @@ private:
bool IsExtbanValid(const Anope::string &mask) override
{
- return mask.length() >= 4 && mask[0] == '~' && mask[2] == ':';
+ Anope::string name, value;
+ return IsExtBan(mask, name, value);
}
void SendLogin(User *u, NickAlias *na) override
@@ -449,20 +474,6 @@ private:
namespace UnrealExtBan
{
- bool IsExtBan(const Anope::string &str, Anope::string &name, Anope::string &value)
- {
- if (str[0] != '~')
- return false;
-
- auto endpos = str.find_first_not_of("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 1);
- if (endpos == Anope::string::npos || str[endpos] != ':' || endpos+1 == str.length())
- return false;
-
- name = str.substr(1, endpos - 1);
- value = str.substr(endpos + 1);
- return true;
- }
-
class Base
: public ChannelModeVirtual<ChannelModeList>
{