]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_nonicks.cpp
Fix segfault in m_chanprotect when OnAccessCheck is called with a null channel
[user/henk/code/inspircd.git] / src / modules / m_nonicks.cpp
index 1a8e83795fcd9992ae657fc00f80037af0015f1f..769097ca0e11a4508bb660ceaee90332c03d9fd4 100644 (file)
@@ -20,7 +20,7 @@ class NoNicks : public ModeHandler
  public:
        NoNicks(InspIRCd* Instance, Module* Creator) : ModeHandler(Instance, Creator, 'N', 0, 0, false, MODETYPE_CHANNEL, false) { }
 
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
+       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
        {
                if (adding)
                {
@@ -70,17 +70,17 @@ class ModuleNoNickChange : public Module
                ServerInstance->AddExtBanChar('N');
        }
 
-       virtual int OnUserPreNick(User* user, const std::string &newnick)
+       virtual ModResult OnUserPreNick(User* user, const std::string &newnick)
        {
                if (!IS_LOCAL(user))
-                       return 0;
+                       return MOD_RES_PASSTHRU;
 
                if (isdigit(newnick[0])) /* don't even think about touching a switch to uid! */
-                       return 0;
+                       return MOD_RES_PASSTHRU;
 
                // Allow forced nick changes.
                if (user->GetExt("NICKForced"))
-                       return 0;
+                       return MOD_RES_PASSTHRU;
 
                for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++)
                {
@@ -89,14 +89,15 @@ class ModuleNoNickChange : public Module
                        if (CHANOPS_EXEMPT(ServerInstance, 'N') && curr->GetStatus(user) == STATUS_OP)
                                continue;
 
-                       if (curr->IsModeSet('N') || curr->GetExtBanStatus(user, 'N') < 0)
+                       if (!curr->GetExtBanStatus(user, 'N').check(!curr->IsModeSet('N')))
                        {
-                               user->WriteNumeric(ERR_CANTCHANGENICK, "%s :Can't change nickname while on %s (+N is set)", user->nick.c_str(), curr->name.c_str());
-                               return 1;
+                               user->WriteNumeric(ERR_CANTCHANGENICK, "%s :Can't change nickname while on %s (+N is set)",
+                                       user->nick.c_str(), curr->name.c_str());
+                               return MOD_RES_DENY;
                        }
                }
 
-               return 0;
+               return MOD_RES_PASSTHRU;
        }
 };