]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Experimental improvements to TreeSocket::Split
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 2 Mar 2006 12:52:45 +0000 (12:52 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 2 Mar 2006 12:52:45 +0000 (12:52 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3418 e03df62e-2008-0410-955e-edbf42e46eb7

src/modules/m_spanningtree.cpp

index f927ac044185841290ffd9e07329043b5d39c189..ce3d00b8c1f3f02059a0957326a38fcbcff4c4a0 100644 (file)
@@ -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);
                }