X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_spanningtree%2Ftreesocket1.cpp;h=2ead91c8ed3fc8e285a54423d9bea03e5ccb8376;hb=d129d452d391e56284672afee74ca90dee0e6580;hp=f0fd0e1ef283852fb2e35d1e6ddc4509414ab37e;hpb=8b1aaa70fadab49c41f2d14cf61f2cf74e878efb;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp index f0fd0e1ef..2ead91c8e 100644 --- a/src/modules/m_spanningtree/treesocket1.cpp +++ b/src/modules/m_spanningtree/treesocket1.cpp @@ -756,7 +756,10 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque &p /* Finally, we can actually place the user into the channel. * We're sure its right. Final answer, phone a friend. */ - chanrec::JoinUser(this->Instance, who, channel.c_str(), true, ""); + if (created) + chanrec::JoinUser(this->Instance, who, channel.c_str(), true, "", TS); + else + chanrec::JoinUser(this->Instance, who, channel.c_str(), true, ""); /* Have we already queued up MAXMODES modes with parameters * (+qaohv) ready to be sent to the server? */ @@ -838,19 +841,6 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque &p for (unsigned int f = 2; f < modectr; f++) free(mode_users[f]); } - /* if we newly created the channel, set it's TS properly. */ - if (created) - { - /* find created channel .. */ - chan = this->Instance->FindChan(channel); - if (chan) - /* w00t said this shouldnt be needed but it is. - * This isnt strictly true, as chan can be NULL - * if a nick collision has occured and therefore - * the channel was never created. - */ - chan->age = TS; - } /* All done. That wasnt so bad was it, you can wipe * the sweat from your forehead now. :-) */ @@ -860,25 +850,60 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque &p /** NICK command */ bool TreeSocket::IntroduceClient(const std::string &source, std::deque ¶ms) { - if (params.size() < 8) - return true; - if (params.size() > 8) + /** Do we have enough parameters: + * NICK age nick host dhost ident +modes ip :gecos + */ + if (params.size() != 8) { this->WriteLine(std::string(":")+this->Instance->Config->ServerName+" KILL "+params[1]+" :Invalid client introduction ("+params[1]+"?)"); return true; } - // NICK age nick host dhost ident +modes ip :gecos - // 0 1 2 3 4 5 6 7 - time_t age = atoi(params[0].c_str()); + time_t age = atoi(params[0].c_str()); const char* tempnick = params[1].c_str(); - Instance->Log(DEBUG,"New remote client %s",tempnick); + /** Check parameters for validity before introducing the client, discovered by dmb. + * XXX: Can we make this neater? + */ + if (!age) + { + this->WriteLine(std::string(":")+this->Instance->Config->ServerName+" KILL "+params[1]+" :Invalid client introduction (Invalid TS?)"); + return true; + } + else if (params[1].length() > NICKMAX) + { + this->WriteLine(std::string(":")+this->Instance->Config->ServerName+" KILL "+params[1]+" :Invalid client introduction ("+params[1]+" > NICKMAX?)"); + return true; + } + else if (params[2].length() > 64) + { + this->WriteLine(std::string(":")+this->Instance->Config->ServerName+" KILL "+params[1]+" :Invalid client introduction ("+params[2]+" > 64?)"); + return true; + } + else if (params[3].length() > 64) + { + this->WriteLine(std::string(":")+this->Instance->Config->ServerName+" KILL "+params[1]+" :Invalid client introduction ("+params[3]+" > 64?)"); + return true; + } + else if (params[4].length() > IDENTMAX) + { + this->WriteLine(std::string(":")+this->Instance->Config->ServerName+" KILL "+params[1]+" :Invalid client introduction ("+params[4]+" > IDENTMAX?)"); + return true; + } + else if (params[7].length() > MAXGECOS) + { + this->WriteLine(std::string(":")+this->Instance->Config->ServerName+" KILL "+params[1]+" :Invalid client introduction ("+params[7]+" > MAXGECOS?)"); + return true; + } + + /** Our client looks ok, lets introduce it now + */ + Instance->Log(DEBUG,"New remote client %s",tempnick); user_hash::iterator iter = this->Instance->clientlist->find(tempnick); if (iter != this->Instance->clientlist->end()) { - // nick collision + /* nick collision */ this->WriteLine(std::string(":")+this->Instance->Config->ServerName+" KILL "+tempnick+" :Nickname collision"); userrec::QuitUser(this->Instance, iter->second, "Nickname collision"); return true; @@ -896,9 +921,7 @@ bool TreeSocket::IntroduceClient(const std::string &source, std::dequeregistered = REG_ALL; _new->signon = age; - /* - * we need to remove the + from the modestring, so we can do our stuff - */ + /* we need to remove the + from the modestring, so we can do our stuff */ std::string::size_type pos_after_plus = params[5].find_first_not_of('+'); if (pos_after_plus != std::string::npos) params[5] = params[5].substr(pos_after_plus);