]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Buffer size limits (hard coded to 1mb for now, will allow to raise in config later)
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 23 May 2005 18:28:42 +0000 (18:28 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 23 May 2005 18:28:42 +0000 (18:28 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1478 e03df62e-2008-0410-955e-edbf42e46eb7

include/connection.h
src/connection.cpp
src/servers.cpp

index 420839b0dc21d2be5fd4318a66069c4d78e2492e..8f5efe2d7dea8c15a44279733d1e16104818de15 100644 (file)
@@ -185,11 +185,10 @@ class ircd_connector : public Extensible
        void CloseConnection();
 
        /** This method adds text to the ircd connection's buffer
        void CloseConnection();
 
        /** This method adds text to the ircd connection's buffer
-        * There is no limitation on how much text of what line width may
-        * be added to this buffer. It is the sending server's responsibility
-        * to ensure sent data is kept within reasonable quanities.
+        * This buffer's maximum size is one megabyte, the method returning false
+        * if the buffer is full.
         */
         */
-       void AddBuffer(std::string a);
+       bool AddBuffer(std::string a);
 
        /** This method returns true if the buffer contains at least one
         * carriage return character, e.g. one line can be read from the
 
        /** This method returns true if the buffer contains at least one
         * carriage return character, e.g. one line can be read from the
index 7d5df66f95c4784be929c2d9faeef5732bad1891..c7221ce740e86e6cb05212b98679e5200e94b15f 100644 (file)
@@ -117,7 +117,7 @@ void ircd_connector::SetServerPort(int p)
        this->port = p;
 }
 
        this->port = p;
 }
 
-void ircd_connector::AddBuffer(std::string a)
+bool ircd_connector::AddBuffer(std::string a)
 {
        std::string b = "";
        for (int i = 0; i < a.length(); i++)
 {
        std::string b = "";
        for (int i = 0; i < a.length(); i++)
@@ -128,6 +128,7 @@ void ircd_connector::AddBuffer(std::string a)
        stream << b;
        log(DEBUG,"AddBuffer: %s",b.c_str());
        ircdbuffer = stream.str();
        stream << b;
        log(DEBUG,"AddBuffer: %s",b.c_str());
        ircdbuffer = stream.str();
+       return (ircdbuffer.length() < 1048576);
 }
 
 bool ircd_connector::BufferIsComplete()
 }
 
 bool ircd_connector::BufferIsComplete()
@@ -170,7 +171,7 @@ bool ircd_connector::AddWriteBuf(std::string data)
         std::stringstream stream;
         stream << sendq << data;
         sendq = stream.str();
         std::stringstream stream;
         stream << sendq << data;
         sendq = stream.str();
-       return true;
+       return (sendq.length() < 1048576);
 }
 
 bool ircd_connector::HasBufferedOutput()
 }
 
 bool ircd_connector::HasBufferedOutput()
index d2ace18e875ef55f02f99a31f1fb544b72189471..15929345f192eae1ef065254c36f387adbbbafbb 100644 (file)
@@ -392,7 +392,12 @@ bool serverrec::RecvPacket(std::deque<std::string> &messages, char* recvhost,std
                         int pushed = 0;
                         if (rcvsize > 0)
                         {
                         int pushed = 0;
                         if (rcvsize > 0)
                         {
-                                this->connectors[i].AddBuffer(data);
+                                if (!this->connectors[i].AddBuffer(data))
+                               {
+                                       WriteOpers("*** Read buffer for %s exceeds maximum, closing connection!",this->connectors[i].GetServerName().c_str());
+                                       this->connectors[i].CloseConnection();
+                                       this->connectors[i].SetState(STATE_DISCONNECTED);
+                               }
                                 if (this->connectors[i].BufferIsComplete())
                                 {
                                         while (this->connectors[i].BufferIsComplete())
                                 if (this->connectors[i].BufferIsComplete())
                                 {
                                         while (this->connectors[i].BufferIsComplete())