From b141ef44b6873789b1d4738b18f8f9d97fce0bf6 Mon Sep 17 00:00:00 2001 From: psychon Date: Tue, 8 Jul 2008 10:00:42 +0000 Subject: [PATCH] Fix a crash with NAMESX If we were joining a channel on a server with NAMESX support while a client was connected that didn't know NAMESX and we received a raw 353 with a trailing whitespace (UnrealIRCd does this), we were calling std::string::at(0) for an empty string, which caused some assert to fail and ZNC to die. This patch fixes this crash bug. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1118 726aef4b-f618-498e-8847-2d620e286838 --- IRCSock.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/IRCSock.cpp b/IRCSock.cpp index c4816e83..157fe362 100644 --- a/IRCSock.cpp +++ b/IRCSock.cpp @@ -352,10 +352,13 @@ void CIRCSock::ReadLine(const CString& sData) { m_pUser->PutUser(sLine, vClients[a]); } else { unsigned int i = 0; - // This loop runs once more than there are nicks, - // the last run sets sNick to "" and causes the break. - do { - sNick = sNicks.Token(i); + // This loop runs once for + // every nick on the channel + for (;;) { + sNick = sNicks.Token(i).Trim_n(" "); + if (sNick.empty()) + break; + if (m_bNamesx && !vClients[a]->HasNamesx() && IsPermChar(sNick[0])) { // Server has, client hasnt NAMESX,