summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar danieldg2010-02-15 03:02:39 +0000
committerGravatar danieldg2010-02-15 03:02:39 +0000
commitace6e82aa9ad64fb77c01272c553667360ffda4e (patch)
tree5e238cd92761c40e33fda02fe8418923e7a4d921
parentCall OnClose() before changing link state to DYING to clean up introduced ser... (diff)
Fix race where two servers with the same name can enter WAIT_AUTH_2 and cause a double-free crash
git-svn-id: http://svn.inspircd.org/repository/branches/1_2_stable@12461 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/modules/m_spanningtree/server.cpp7
-rw-r--r--src/modules/m_spanningtree/treesocket2.cpp11
2 files changed, 9 insertions, 9 deletions
diff --git a/src/modules/m_spanningtree/server.cpp b/src/modules/m_spanningtree/server.cpp
index fcf3bbfa0..c75298bad 100644
--- a/src/modules/m_spanningtree/server.cpp
+++ b/src/modules/m_spanningtree/server.cpp
@@ -264,6 +264,13 @@ bool TreeSocket::Inbound_Server(std::deque<std::string> &params)
this->SendCapabilities();
this->WriteLine(std::string("SERVER ")+this->ServerInstance->Config->ServerName+" "+this->MakePass(x->SendPass, this->GetTheirChallenge())+" 0 "+ServerInstance->Config->GetSID()+" :"+this->ServerInstance->Config->ServerDesc);
// move to the next state, we are now waiting for THEM.
+
+ Link* lnk = Utils->FindLink(InboundServerName);
+
+ TreeServer* Node = new TreeServer(this->Utils, this->ServerInstance, InboundServerName, InboundDescription, InboundSID, Utils->TreeRoot, this, lnk ? lnk->Hidden : false);
+
+ Utils->TreeRoot->AddChild(Node);
+ Node->bursting = true;
this->LinkState = WAIT_AUTH_2;
return true;
}
diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp
index 713f5d108..4e7d4da47 100644
--- a/src/modules/m_spanningtree/treesocket2.cpp
+++ b/src/modules/m_spanningtree/treesocket2.cpp
@@ -96,8 +96,6 @@ bool TreeSocket::ProcessLine(std::string &line)
switch (this->LinkState)
{
- TreeServer* Node;
-
case DYING:
return false;
case WAIT_AUTH_1:
@@ -179,12 +177,8 @@ bool TreeSocket::ProcessLine(std::string &line)
this->LinkState = CONNECTED;
Utils->timeoutlist.erase(this);
+ TreeServer *Node = Utils->FindServer(InboundServerName);
- Link* lnk = Utils->FindLink(InboundServerName);
-
- Node = new TreeServer(this->Utils, this->ServerInstance, InboundServerName, InboundDescription, InboundSID, Utils->TreeRoot, this, lnk ? lnk->Hidden : false);
-
- Utils->TreeRoot->AddChild(Node);
parameterlist sparams;
sparams.push_back(InboundServerName);
sparams.push_back("*");
@@ -193,7 +187,6 @@ bool TreeSocket::ProcessLine(std::string &line)
sparams.push_back(":"+InboundDescription);
Utils->DoOneToAllButSender(ServerInstance->Config->GetSID(),"SERVER",sparams,InboundServerName);
Utils->DoOneToAllButSenderRaw(line, InboundServerName, prefix, command, params);
- Node->bursting = true;
this->DoBurst(Node);
}
else if (command == "ERROR")
@@ -619,7 +612,7 @@ void TreeSocket::OnTimeout()
void TreeSocket::OnClose()
{
// Test fix for big fuckup
- if (this->LinkState != CONNECTED)
+ if (this->LinkState != CONNECTED && this->LinkState != WAIT_AUTH_2)
return;
// Connection closed.