From 537b66ad992f7094793c7e025af4d06b30ef35ee Mon Sep 17 00:00:00 2001 From: w00t Date: Wed, 4 Jan 2006 05:52:34 +0000 Subject: Revise some serious craq++ in AddBan git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2730 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/mode.cpp | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'src') 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); -- cgit v1.2.3