mirror of
https://github.com/znc/znc.git
synced 2026-05-07 13:54:47 +02:00
CIncomingConnection: Reject long input lines
This should make DoS attacks that try to make znc eat lots of memory a lot harder to do (= Don't bother trying). git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2124 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
@@ -76,6 +76,19 @@ CIncomingConnection::CIncomingConnection(const CString& sHostname, unsigned shor
|
||||
EnableReadLine();
|
||||
}
|
||||
|
||||
void CIncomingConnection::ReachedMaxBuffer() {
|
||||
if (GetCloseType() != CLT_DONT)
|
||||
return; // Already closing
|
||||
|
||||
// We don't actually SetMaxBufferThreshold() because that would be
|
||||
// inherited by sockets after SwapSockByAddr().
|
||||
if (GetInternalReadBuffer().length() <= 4096)
|
||||
return;
|
||||
|
||||
// We should never get here with legitimate requests :/
|
||||
Close();
|
||||
}
|
||||
|
||||
void CIncomingConnection::ReadLine(const CString& sLine) {
|
||||
bool bIsHTTP = (sLine.WildCmp("GET * HTTP/1.?\r\n") || sLine.WildCmp("POST * HTTP/1.?\r\n"));
|
||||
bool bAcceptHTTP = (m_eAcceptType == CListener::ACCEPT_ALL)
|
||||
|
||||
Reference in New Issue
Block a user