summaryrefslogtreecommitdiff
path: root/src/mode.cpp
diff options
context:
space:
mode:
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2006-01-04 05:52:34 +0000
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2006-01-04 05:52:34 +0000
commit537b66ad992f7094793c7e025af4d06b30ef35ee (patch)
treef7e8171080518bfa090a754a69b561e2897f05f5 /src/mode.cpp
parentc992372f80a3668ca3dd1b62ebe7b8284111bd0a (diff)
Revise some serious craq++ in AddBan
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2730 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/mode.cpp')
-rw-r--r--src/mode.cpp35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/mode.cpp b/src/mode.cpp
index 3302b0042..24531651a 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -370,35 +370,36 @@ char* ModeParser::TakeVoice(userrec *user,char *dest,chanrec *chan,int status)
char* ModeParser::AddBan(userrec *user,char *dest,chanrec *chan,int status)
{
- if ((!user) || (!dest) || (!chan) || (!*dest)) {
+ BanItem b;
+ unsigned int l;
+ int toomanyexclamation = 0;
+ int toomanyat = 0;
+
+ if ((!user) || (!dest) || (!chan) || (!*dest))
+ {
log(DEFAULT,"*** BUG *** AddBan was given an invalid parameter");
return NULL;
}
- BanItem b;
+ l = strlen(dest);
- unsigned int l = strlen(dest);
- if (strchr(dest,'!')==0)
- return NULL;
- if (strchr(dest,'@')==0)
- return NULL;
for (unsigned int i = 0; i < l; i++)
+ {
if (dest[i] < 32)
return NULL;
- for (unsigned int i = 0; i < l; i++)
if (dest[i] > 126)
return NULL;
- int c = 0;
- for (unsigned int i = 0; i < l; i++)
if (dest[i] == '!')
- c++;
- if (c>1)
- return NULL;
- c = 0;
- for (unsigned int i = 0; i < l; i++)
+ toomanyexclamation++;
if (dest[i] == '@')
- c++;
- if (c>1)
+ toomanyat++;
+ }
+
+ if (toomanyexclamation != 1 || toomanyat != 1)
+ /*
+ * this stops sillyness like n!u!u!u@h, though note that most
+ * ircds don't actually verify banmask validity. --w00t
+ */
return NULL;
long maxbans = GetMaxBans(chan->name);