mirror of
https://github.com/znc/znc.git
synced 2026-08-08 01:43:03 +02:00
Fix a user-after-free bug
When a user is deleted we didn't properly clean up after it. Active DCC connections (CDCCBounce and CDCCSock) where left laying around and at some later point of time they used their CUser* pointer which now pointed to invalid data. This bug is similar to the one from r1557. Thanks to cnu, our beloved master of destruction, for finding yet another way to make ZNC break and for testing the patch. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1575 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
+38
-4
@@ -10,15 +10,49 @@
|
||||
#include "User.h"
|
||||
#include "Utils.h"
|
||||
|
||||
CDCCSock::CDCCSock(CUser* pUser, const CString& sRemoteNick, const CString& sLocalFile, const CString& sModuleName,
|
||||
unsigned long uFileSize, CFile* pFile) : CZNCSock() {
|
||||
m_sRemoteNick = sRemoteNick;
|
||||
m_uFileSize = uFileSize;
|
||||
m_uRemotePort = 0;
|
||||
m_uBytesSoFar = 0;
|
||||
m_pUser = pUser;
|
||||
m_pFile = pFile;
|
||||
m_sLocalFile = sLocalFile;
|
||||
m_sModuleName = sModuleName;
|
||||
m_bSend = true;
|
||||
m_bNoDelFile = false;
|
||||
|
||||
m_pUser->AddDCCSock(this);
|
||||
}
|
||||
|
||||
CDCCSock::CDCCSock(CUser* pUser, const CString& sRemoteNick, const CString& sRemoteIP, unsigned short uRemotePort,
|
||||
const CString& sLocalFile, unsigned long uFileSize, const CString& sModuleName) : CZNCSock() {
|
||||
m_sRemoteNick = sRemoteNick;
|
||||
m_sRemoteIP = sRemoteIP;
|
||||
m_uRemotePort = uRemotePort;
|
||||
m_uFileSize = uFileSize;
|
||||
m_uBytesSoFar = 0;
|
||||
m_pUser = pUser;
|
||||
m_pFile = NULL;
|
||||
m_sLocalFile = sLocalFile;
|
||||
m_sModuleName = sModuleName;
|
||||
m_bSend = false;
|
||||
m_bNoDelFile = false;
|
||||
|
||||
m_pUser->AddDCCSock(this);
|
||||
}
|
||||
|
||||
CDCCSock::~CDCCSock() {
|
||||
if ((m_pFile) && (!m_bNoDelFile)) {
|
||||
m_pFile->Close();
|
||||
delete m_pFile;
|
||||
}
|
||||
if (m_pUser) {
|
||||
m_pUser->AddBytesRead(GetBytesRead());
|
||||
m_pUser->AddBytesWritten(GetBytesWritten());
|
||||
}
|
||||
|
||||
m_pUser->AddBytesRead(GetBytesRead());
|
||||
m_pUser->AddBytesWritten(GetBytesWritten());
|
||||
|
||||
m_pUser->DelDCCSock(this);
|
||||
}
|
||||
|
||||
void CDCCSock::ReadData(const char* data, int len) {
|
||||
|
||||
Reference in New Issue
Block a user