From e86008ffe0f730d5fbffa43abd8bb53439d2a48e Mon Sep 17 00:00:00 2001 From: psychon Date: Tue, 3 Aug 2010 09:50:32 +0000 Subject: [PATCH] Fix an out-of-range access to std::string When we received a "PING" from a client without an argument, std::string would throw a std::out_of_range exception which killed znc. Thanks to Sm0ke0ut for reporting this. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2093 726aef4b-f618-498e-8847-2d620e286838 --- Client.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Client.cpp b/Client.cpp index 13918e91..acef5e7e 100644 --- a/Client.cpp +++ b/Client.cpp @@ -180,7 +180,10 @@ void CClient::ReadLine(const CString& sData) { } else if (sCommand.Equals("PING")) { // All PONGs are generated by znc. We will still forward this to // the ircd, but all PONGs from irc will be blocked. - PutClient(":irc.znc.in PONG irc.znc.in " + sLine.substr(5)); + if (sLine.length() >= 5) + PutClient(":irc.znc.in PONG irc.znc.in " + sLine.substr(5)); + else + PutClient(":irc.znc.in PONG irc.znc.in"); } else if (sCommand.Equals("PONG")) { // Block PONGs, we already responded to the pings return;