mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
Limit the maximal read buffer space that is used for every socket
CSocket caches the data read from a socket and then looks for lines in there. If there is no line end, this buffer can grow quite large. This patch now closes sockets if they get a huge read buffer. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1233 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
@@ -36,6 +36,9 @@ CIRCSock::CIRCSock(CUser* pUser) : Csock() {
|
||||
m_mueChanModes['t'] = NoArg;
|
||||
m_mueChanModes['i'] = NoArg;
|
||||
m_mueChanModes['n'] = NoArg;
|
||||
|
||||
// RFC says a line can have 512 chars max, but we don't care ;)
|
||||
SetMaxBufferThreshold(1024);
|
||||
}
|
||||
|
||||
CIRCSock::~CIRCSock() {
|
||||
@@ -878,6 +881,12 @@ void CIRCSock::ConnectionRefused() {
|
||||
m_pUser->ClearMotdBuffer();
|
||||
}
|
||||
|
||||
void CIRCSock::ReachedMaxBuffer() {
|
||||
DEBUG_ONLY(cout << GetSockName() << " == ReachedMaxBuffer()" << endl);
|
||||
m_pUser->PutStatus("Received a too long line from the IRC server!");
|
||||
Quit();
|
||||
}
|
||||
|
||||
void CIRCSock::ParseISupport(const CString& sLine) {
|
||||
unsigned int i = 0;
|
||||
CString sArg = sLine.Token(i++);
|
||||
|
||||
Reference in New Issue
Block a user