]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fix bursting channel bans
authorAdam <Adam@anope.org>
Fri, 29 Jul 2016 17:09:43 +0000 (13:09 -0400)
committerAdam <Adam@anope.org>
Mon, 1 Aug 2016 13:28:22 +0000 (09:28 -0400)
src/modules/m_spanningtree/netburst.cpp
src/modules/m_spanningtree/treesocket.h

index d508c092dd00fea08c6fb87a365fb8b64e6da736..3bce90eda30895bcb1be9cf67d013ffcfe607e41 100644 (file)
@@ -140,25 +140,28 @@ void TreeSocket::SendFJoins(Channel* c)
                buffer.append(list).append("\r\n");
        }
 
-       int linesize = 1;
+       unsigned int linesize = 1;
        for (BanList::iterator b = c->bans.begin(); b != c->bans.end(); b++)
        {
-               int size = b->data.length() + 2;
-               int currsize = linesize + size;
-               if (currsize <= 350)
-               {
-                       modes.append("b");
-                       params.append(" ").append(b->data);
-                       linesize += size;
-               }
-               if ((modes.length() >= ServerInstance->Config->Limits.MaxModes) || (currsize > 350))
+               unsigned int size = b->data.length() + 2; // "b" and " "
+               unsigned int nextsize = linesize + size;
+
+               if ((modes.length() >= ServerInstance->Config->Limits.MaxModes) || (nextsize > FMODE_MAX_LENGTH))
                {
-                       /* Wrap at MAXMODES */
+                       /* Wrap */
                        buffer.append(":").append(ServerInstance->Config->GetSID()).append(" FMODE ").append(c->name).append(" ").append(ConvToStr(c->age)).append(" +").append(modes).append(params).append("\r\n");
+
                        modes.clear();
                        params.clear();
                        linesize = 1;
                }
+
+               modes.push_back('b');
+
+               params.push_back(' ');
+               params.append(b->data);
+
+               linesize += size;
        }
 
        /* Only send these if there are any */
index abda283353def3e2fab90d2ea4cdf04593f80f76..efcce5f7a3e46463eb71eb061d0c525f06da7a1d 100644 (file)
@@ -100,6 +100,8 @@ class TreeSocket : public BufferedSocket
        int proto_version;                      /* Remote protocol version */
        bool ConnectionFailureShown; /* Set to true if a connection failure message was shown */
 
+       static const unsigned int FMODE_MAX_LENGTH = 350;
+
        /** Checks if the given servername and sid are both free
         */
        bool CheckDuplicate(const std::string& servername, const std::string& sid);