From 8cce595fbe5b541ee8bd6ad3fef3b22eff99be82 Mon Sep 17 00:00:00 2001 From: Kyle Fuller Date: Thu, 20 Oct 2011 23:22:44 +0000 Subject: [PATCH] antiidle: Don't SIGABRT when receiving a line with less than 2 words This was introduced in 232d2612fea1230681d9c55d74eaab09b273206f which tries to split a line by spaces and then tries splitted[1] and splitted[2] which will cause a SIGABRT if the line isn't actually that long. This also uses the 4th argument to the 301 line to determine if this message is because we sent a message to ourselfs. Previously the 3rd option was used, which is always our own nick. This was resulting in any 301 line being halted. --- modules/extra/antiidle.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/extra/antiidle.cpp b/modules/extra/antiidle.cpp index 9bdc8c65..23add843 100644 --- a/modules/extra/antiidle.cpp +++ b/modules/extra/antiidle.cpp @@ -72,12 +72,15 @@ public: return CONTINUE; } - virtual EModRet OnRaw(CString &sLine) - { - VCString splitted; - sLine.Split(" ",splitted); - if(splitted[1] == "301" && splitted[2].TrimPrefix_n(":").Equals(m_pNetwork->GetIRCNick().GetNick())) + virtual EModRet OnRaw(CString &sLine) { + /* If we send a message to ourselfs while we are away, this + * will result in the server sending a 301 which we shouldn't + * forward to the client */ + + if (sLine.Token(1).Equals("301") && sLine.Token(3).Equals(m_pNetwork->GetIRCNick().GetNick())) { return HALT; + } + return CONTINUE; }