From a436c0371dd9c013e523b18e86e19e5631f4970f Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 13 Jan 2006 16:14:57 +0000 Subject: [PATCH] Added extra safety check for a condition that should NOT happen (in theory, but still) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2785 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_spanningtree.cpp | 97 ++++++++++++++++++---------------- 1 file changed, 51 insertions(+), 46 deletions(-) diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index d8f4821ba..0ecc595fc 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -927,56 +927,61 @@ class TreeSocket : public InspSocket { /* process one channel at a time, applying modes. */ char* usr = (char*)params[usernum].c_str(); - char permissions = *usr; - switch (permissions) - { - case '@': - usr++; - mode_users[modectr++] = usr; - strlcat(modestring,"o",MAXBUF); - break; - case '%': - usr++; - mode_users[modectr++] = usr; - strlcat(modestring,"h",MAXBUF); - break; - case '+': - usr++; - mode_users[modectr++] = usr; - strlcat(modestring,"v",MAXBUF); - break; - } - who = Srv->FindNick(usr); - if (who) - { - Srv->JoinUserToChannel(who,channel,key); - if (modectr >= (MAXMODES-1)) - { - /* theres a mode for this user. push them onto the mode queue, and flush it - * if there are more than MAXMODES to go. - */ - if ((ourTS >= TS) || (Srv->IsUlined(who->server))) - { - /* We also always let u-lined clients win, no matter what the TS value */ - log(DEBUG,"Our our channel newer than theirs, accepting their modes"); - Srv->SendMode(mode_users,modectr,who); - } - else + /* Safety check just to make sure someones not sent us an FJOIN full of spaces + * (is this even possible?) */ + if (usr && *usr) + { + char permissions = *usr; + switch (permissions) + { + case '@': + usr++; + mode_users[modectr++] = usr; + strlcat(modestring,"o",MAXBUF); + break; + case '%': + usr++; + mode_users[modectr++] = usr; + strlcat(modestring,"h",MAXBUF); + break; + case '+': + usr++; + mode_users[modectr++] = usr; + strlcat(modestring,"v",MAXBUF); + break; + } + who = Srv->FindNick(usr); + if (who) + { + Srv->JoinUserToChannel(who,channel,key); + if (modectr >= (MAXMODES-1)) { - log(DEBUG,"Their channel newer than ours, bouncing their modes"); - /* bouncy bouncy! */ - std::deque params; - /* modes are now being UNSET... */ - *mode_users[1] = '-'; - for (unsigned int x = 0; x < modectr; x++) + /* theres a mode for this user. push them onto the mode queue, and flush it + * if there are more than MAXMODES to go. + */ + if ((ourTS >= TS) || (Srv->IsUlined(who->server))) + { + /* We also always let u-lined clients win, no matter what the TS value */ + log(DEBUG,"Our our channel newer than theirs, accepting their modes"); + Srv->SendMode(mode_users,modectr,who); + } + else { - params.push_back(mode_users[x]); + log(DEBUG,"Their channel newer than ours, bouncing their modes"); + /* bouncy bouncy! */ + std::deque params; + /* modes are now being UNSET... */ + *mode_users[1] = '-'; + for (unsigned int x = 0; x < modectr; x++) + { + params.push_back(mode_users[x]); + } + // tell everyone to bounce the modes. bad modes, bad! + DoOneToMany(Srv->GetServerName(),"FMODE",params); } - // tell everyone to bounce the modes. bad modes, bad! - DoOneToMany(Srv->GetServerName(),"FMODE",params); + strcpy(mode_users[1],"+"); + modectr = 2; } - strcpy(mode_users[1],"+"); - modectr = 2; } } } -- 2.39.5