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
This commit is contained in:
psychon
2010-08-03 09:50:32 +00:00
parent 564226c0ec
commit e86008ffe0

View File

@@ -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;