From f8e460b127b3d8f57e42276016dc94dd5d4ecf82 Mon Sep 17 00:00:00 2001 From: w00t Date: Mon, 27 Aug 2007 22:08:34 +0000 Subject: Fix to use DuplicateID. This stops things segfaulting on duplicate SID introduction, which is, of course, bad. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7923 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_spanningtree/treesocket2.cpp | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp index fefd25b2a..4d62c3b83 100644 --- a/src/modules/m_spanningtree/treesocket2.cpp +++ b/src/modules/m_spanningtree/treesocket2.cpp @@ -801,13 +801,9 @@ bool TreeSocket::RemoteServer(const std::string &prefix, std::deque } Link* lnk = Utils->FindLink(servername); - TreeServer *Node; + TreeServer *Node = new TreeServer(this->Utils, this->Instance, servername, description, sid, ParentOfThis,NULL, lnk ? lnk->Hidden : false); - try - { - Node = new TreeServer(this->Utils, this->Instance, servername, description, sid, ParentOfThis,NULL, lnk ? lnk->Hidden : false); - } - catch (CoreException &e) + if (Node->DuplicateID()) { this->SendError("Server ID "+sid+" already exists on the network!"); this->Instance->SNO->WriteToSnoMask('l',"Server \2"+servername+"\2 being introduced from \2" + prefix + "\2 denied, server ID already exists on the network. Closing link with " + prefix); @@ -886,18 +882,15 @@ bool TreeSocket::Outbound_Reply_Server(std::deque ¶ms) // to the servers tree, as a child of the root // node. - TreeServer *Node; + TreeServer *Node = new TreeServer(this->Utils, this->Instance, sname, description, sid, Utils->TreeRoot, this, x->Hidden); - try - { - Node = new TreeServer(this->Utils, this->Instance, sname, description, sid, Utils->TreeRoot, this, x->Hidden); - } - catch (CoreException &e) + if (Node->DuplicateID()) { this->SendError("Server ID "+sid+" already exists on the network!"); this->Instance->SNO->WriteToSnoMask('l',"Server \2"+assign(servername)+"\2 being introduced denied, server ID already exists on the network. Closing link."); return false; } + Utils->TreeRoot->AddChild(Node); params[4] = ":" + params[4]; Utils->DoOneToAllButSender(Utils->TreeRoot->GetName(),"SERVER",params,sname); @@ -1099,11 +1092,10 @@ bool TreeSocket::ProcessLine(std::string &line) } this->LinkState = CONNECTED; Link* lnk = Utils->FindLink(InboundServerName); - try - { - Node = new TreeServer(this->Utils,this->Instance, InboundServerName, InboundDescription, InboundSID, Utils->TreeRoot, this, lnk ? lnk->Hidden : false); - } - catch (CoreException &e) + + Node = new TreeServer(this->Utils,this->Instance, InboundServerName, InboundDescription, InboundSID, Utils->TreeRoot, this, lnk ? lnk->Hidden : false); + + if (Node->DuplicateID()) { this->SendError("Server ID "+InboundSID+" already exists on the network!"); this->Instance->SNO->WriteToSnoMask('l',"Server \2"+InboundServerName+"\2 being introduced from \2" + prefix + "\2 denied, server ID already exists on the network. Closing link."); -- cgit v1.2.3