summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorDaniel De Graaf <danieldg@inspircd.org>2010-09-04 16:36:17 -0400
committerDaniel De Graaf <danieldg@inspircd.org>2010-09-04 16:36:17 -0400
commit3ee7abb7b9127edd8b730602376a9e827afb95f6 (patch)
treed0abca7b5ed50a539605d31ba6a42d398884bec8 /src/modules
parent33f4713fbdb53a22abec11bf78d192447f66b5e7 (diff)
Fix crash in m_silence when provided with a bad pattern (bug #79)
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_silence.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp
index 8c26051db..7925fd8d8 100644
--- a/src/modules/m_silence.cpp
+++ b/src/modules/m_silence.cpp
@@ -135,6 +135,12 @@ class CommandSilence : public Command
pattern = CompilePattern(parameters[1].c_str());
}
+ if (pattern == 0)
+ {
+ user->WriteServ("NOTICE %s :Bad SILENCE pattern",user->nick.c_str());
+ return CMD_INVALID;
+ }
+
if (!mask.length())
{
// 'SILENCE +' or 'SILENCE -', assume *!*@*
@@ -247,21 +253,24 @@ class CommandSilence : public Command
std::string DecompPattern (const int pattern)
{
std::string out;
- if ((pattern & SILENCE_PRIVATE) > 0)
+ if (pattern & SILENCE_PRIVATE)
out += ",privatemessages";
- if ((pattern & SILENCE_CHANNEL) > 0)
+ if (pattern & SILENCE_CHANNEL)
out += ",channelmessages";
- if ((pattern & SILENCE_INVITE) > 0)
+ if (pattern & SILENCE_INVITE)
out += ",invites";
- if ((pattern & SILENCE_NOTICE) > 0)
+ if (pattern & SILENCE_NOTICE)
out += ",privatenotices";
- if ((pattern & SILENCE_CNOTICE) > 0)
+ if (pattern & SILENCE_CNOTICE)
out += ",channelnotices";
- if ((pattern & SILENCE_ALL) > 0)
+ if (pattern & SILENCE_ALL)
out = ",all";
- if ((pattern & SILENCE_EXCLUDE) > 0)
+ if (pattern & SILENCE_EXCLUDE)
out += ",exclude";
- return "<" + out.substr(1) + ">";
+ if (out.length())
+ return "<" + out.substr(1) + ">";
+ else
+ return "<none>";
}
};