summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2019-07-31 21:49:47 +0100
committerPeter Powell <petpow@saberuk.com>2019-07-31 21:50:48 +0100
commit7d17f0f275b4cb9971a9f2ce1a641d4c6f060096 (patch)
tree44fc06cd9311c5703be4a492a021ad9aa4e935a0
parentef77989a9d067de7a51fcfae16df82f390ff5bb5 (diff)
Fix extban O matching against oper types containing spaces.
Fixes #1684.
-rw-r--r--src/modules/m_operchans.cpp35
1 files changed, 28 insertions, 7 deletions
diff --git a/src/modules/m_operchans.cpp b/src/modules/m_operchans.cpp
index 8484d7dcc..8f6003923 100644
--- a/src/modules/m_operchans.cpp
+++ b/src/modules/m_operchans.cpp
@@ -40,9 +40,16 @@ class OperChans : public SimpleChannelModeHandler
class ModuleOperChans : public Module
{
+ private:
OperChans oc;
+ std::string space;
+ std::string underscore;
+
public:
- ModuleOperChans() : oc(this)
+ ModuleOperChans()
+ : oc(this)
+ , space(" ")
+ , underscore("_")
{
}
@@ -56,13 +63,27 @@ class ModuleOperChans : public Module
return MOD_RES_PASSTHRU;
}
- ModResult OnCheckBan(User *user, Channel *c, const std::string& mask) CXX11_OVERRIDE
+ ModResult OnCheckBan(User* user, Channel* chan, const std::string& mask) CXX11_OVERRIDE
{
- if ((mask.length() > 2) && (mask[0] == 'O') && (mask[1] == ':'))
- {
- if (user->IsOper() && InspIRCd::Match(user->oper->name, mask.substr(2)))
- return MOD_RES_DENY;
- }
+ // Check whether the entry is an extban.
+ if (mask.length() <= 2 || mask[0] != 'O' || mask[1] != ':')
+ return MOD_RES_PASSTHRU;
+
+ // If the user is not an oper they can't match this.
+ if (!user->IsOper())
+ return MOD_RES_PASSTHRU;
+
+ // Check whether the oper's type matches the ban.
+ const std::string submask = mask.substr(2);
+ if (InspIRCd::Match(user->oper->name, submask))
+ return MOD_RES_DENY;
+
+ // If the oper's type contains spaces recheck with underscores.
+ std::string opername(user->oper->name);
+ stdalgo::string::replace_all(opername, space, underscore);
+ if (InspIRCd::Match(opername, submask))
+ return MOD_RES_DENY;
+
return MOD_RES_PASSTHRU;
}