]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/channels.cpp
Merge pull request #971 from SaberUK/master+numeric-xline
[user/henk/code/inspircd.git] / src / channels.cpp
index 2ea8688cf51c311e7c0279501d400b1bd6279d5f..948538ff460d15162048800ceea8c77a218f5954 100644 (file)
@@ -86,14 +86,13 @@ void Channel::CheckDestroy()
        if (res == MOD_RES_DENY)
                return;
 
+       // If the channel isn't in chanlist then it is already in the cull list, don't add it again
        chan_hash::iterator iter = ServerInstance->chanlist.find(this->name);
-       /* kill the record */
-       if (iter != ServerInstance->chanlist.end())
-       {
-               FOREACH_MOD(OnChannelDelete, (this));
-               ServerInstance->chanlist.erase(iter);
-       }
+       if ((iter == ServerInstance->chanlist.end()) || (iter->second != this))
+               return;
 
+       FOREACH_MOD(OnChannelDelete, (this));
+       ServerInstance->chanlist.erase(iter);
        ClearInvites();
        ServerInstance->GlobalCulls.AddItem(this);
 }
@@ -136,10 +135,18 @@ void Channel::SetDefaultModes()
                                continue;
 
                        if (mode->GetNumParams(true))
+                       {
                                list.GetToken(parameter);
+                               // If the parameter begins with a ':' then it's invalid
+                               if (parameter.c_str()[0] == ':')
+                                       continue;
+                       }
                        else
                                parameter.clear();
 
+                       if ((mode->GetNumParams(true)) && (parameter.empty()))
+                               continue;
+
                        mode->OnModeChange(ServerInstance->FakeClient, ServerInstance->FakeClient, this, parameter, true);
                }
        }
@@ -388,10 +395,10 @@ bool Channel::CheckBan(User* user, const std::string& mask)
                return false;
 
        const std::string nickIdent = user->nick + "!" + user->ident;
-       std::string prefix = mask.substr(0, at);
+       std::string prefix(mask, 0, at);
        if (InspIRCd::Match(nickIdent, prefix, NULL))
        {
-               std::string suffix = mask.substr(at + 1);
+               std::string suffix(mask, at + 1);
                if (InspIRCd::Match(user->host, suffix, NULL) ||
                        InspIRCd::Match(user->dhost, suffix, NULL) ||
                        InspIRCd::MatchCIDR(user->GetIPString(), suffix, NULL))