Permalink
Browse files

antiidle: Don't SIGABRT when receiving a line with less than 2 words

This was introduced in 232d261 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.
  • Loading branch information...
1 parent 71636d2 commit 8cce595fbe5b541ee8bd6ad3fef3b22eff99be82 @kylef kylef committed Oct 20, 2011
Showing with 8 additions and 5 deletions.
  1. +8 −5 modules/extra/antiidle.cpp
@@ -72,12 +72,15 @@ class CAntiIdle : public CModule
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;
}

0 comments on commit 8cce595

Please sign in to comment.