]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree.cpp
Experimental improvements to TreeSocket::Split
[user/henk/code/inspircd.git] / src / modules / m_spanningtree.cpp
index 636d7e89593ca164a6a5b38d2470a21467e3290f..ce3d00b8c1f3f02059a0957326a38fcbcff4c4a0 100644 (file)
@@ -1429,7 +1429,7 @@ class TreeSocket : public InspSocket
                                                if ((nbytes > 0) && (nbytes < 1024))
                                                {
                                                        log(DEBUG,"m_spanningtree: decrypt %d bytes",nbytes);
-                                                       ctx_in->Decrypt(out, result, nbytes, 1);
+                                                       ctx_in->Decrypt(out, result, nbytes, 0);
                                                        for (int t = 0; t < nbytes; t++)
                                                                if (result[t] == '\7') result[t] = 0;
                                                        ret = result;
@@ -1468,7 +1468,7 @@ class TreeSocket : public InspSocket
                                }
                        }
                        unsigned int ll = line.length();
-                       ctx_out->Encrypt(line.c_str(), result, ll, 1);
+                       ctx_out->Encrypt(line.c_str(), result, ll, 0);
                        to64frombits((unsigned char*)result64,(unsigned char*)result,ll);
                        line = result64;
                        //int from64tobits(char *out, const char *in, int maxlen);
@@ -2072,13 +2072,18 @@ class TreeSocket : public InspSocket
 
        void Split(std::string line, bool stripcolon, std::deque<std::string> &n)
        {
+               // we don't do anything with a line > 2048
+               if (line.length() > 2048)
+                       return;
                if (!strchr(line.c_str(),' '))
                {
                        n.push_back(line);
                        return;
                }
                std::stringstream s(line);
-               std::string param = "";
+               int count = 0;
+               char param[1024];
+               char* pptr = param;
 
                n.clear();
                int item = 0;
@@ -2089,32 +2094,34 @@ class TreeSocket : public InspSocket
                        if (c == ' ')
                        {
                                n.push_back(param);
-                               param = "";
+                               *param = count = 0;
                                item++;
                        }
                        else
                        {
                                if (!s.eof())
                                {
-                                       param = param + c;
+                                       *pptr++ = c;
+                                       count++;
                                }
-                               if ((param == ":") && (item > 0))
+                               if ((*param == ':') && (count == 1) && (item > 0))
                                {
-                                       param = "";
+                                       *param = 0;
                                        while (!s.eof())
                                        {
                                                s.get(c);
                                                if (!s.eof())
                                                {
-                                                       param = param + c;
+                                                       *pptr++ = c;
+                                                       count++;
                                                }
                                        }
                                        n.push_back(param);
-                                       param = "";
+                                       *param = count = 0;
                                }
                        }
                }
-               if (param != "")
+               if (*param)
                {
                        n.push_back(param);
                }
@@ -2459,6 +2466,12 @@ class TreeSocket : public InspSocket
                                {
                                        this->bursting = false;
                                        apply_lines(APPLY_ZLINES|APPLY_GLINES|APPLY_QLINES);
+                                       std::string sourceserv = this->myhost;
+                                       if (this->InboundServerName != "")
+                                       {
+                                               sourceserv = this->InboundServerName;
+                                       }
+                                       WriteOpers("*** Received end of netburst from \2%s\2",sourceserv.c_str());
                                        return true;
                                }
                                else
@@ -2507,7 +2520,11 @@ class TreeSocket : public InspSocket
                                                {
                                                        strparams[q] = (char*)params[q].c_str();
                                                }
-                                               Srv->CallCommandHandler(command.c_str(), strparams, params.size(), who);
+                                               if (!Srv->CallCommandHandler(command.c_str(), strparams, params.size(), who))
+                                               {
+                                                       this->WriteLine("ERROR :Unrecognised command -- possibly loaded mismatched modules");
+                                                       return false;
+                                               }
                                        }
                                        else
                                        {