Forwardport fix from stable (bug#133 reported by insurgent): configuring a link block with the same name as the local server (?!) then linking to it causes segfault

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5090 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
brain 2006-08-31 16:43:35 +00:00
parent f33f516fef
commit 134e29c6b7

View File

@ -3577,53 +3577,60 @@ void ReadConfiguration(bool rebind)
L.HiddenFromStats = Conf->ReadFlag("link","hidden",j);
L.NextConnectTime = time(NULL) + L.AutoConnect;
/* Bugfix by brain, do not allow people to enter bad configurations */
if ((L.IPAddr != "") && (L.RecvPass != "") && (L.SendPass != "") && (L.Name != "") && (L.Port))
if (L.Name != ServerInstance->Config->ServerName)
{
ValidIPs.push_back(L.IPAddr);
if (Allow.length())
ValidIPs.push_back(Allow);
/* Needs resolving */
insp_inaddr binip;
if (insp_aton(L.IPAddr.c_str(), &binip) < 1)
if ((L.IPAddr != "") && (L.RecvPass != "") && (L.SendPass != "") && (L.Name != "") && (L.Port))
{
try
ValidIPs.push_back(L.IPAddr);
if (Allow.length())
ValidIPs.push_back(Allow);
/* Needs resolving */
insp_inaddr binip;
if (insp_aton(L.IPAddr.c_str(), &binip) < 1)
{
SecurityIPResolver* sr = new SecurityIPResolver(ServerInstance, L.IPAddr, L);
ServerInstance->AddResolver(sr);
try
{
SecurityIPResolver* sr = new SecurityIPResolver(ServerInstance, L.IPAddr, L);
ServerInstance->AddResolver(sr);
}
catch (ModuleException& e)
{
ServerInstance->Log(DEBUG,"Error in resolver: %s",e.GetReason());
}
}
catch (ModuleException& e)
LinkBlocks.push_back(L);
ServerInstance->Log(DEBUG,"m_spanningtree: Read server %s with host %s:%d",L.Name.c_str(),L.IPAddr.c_str(),L.Port);
}
else
{
if (L.IPAddr == "")
{
ServerInstance->Log(DEBUG,"Error in resolver: %s",e.GetReason());
ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', IP address not defined!",L.Name.c_str());
}
else if (L.RecvPass == "")
{
ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', recvpass not defined!",L.Name.c_str());
}
else if (L.SendPass == "")
{
ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', sendpass not defined!",L.Name.c_str());
}
else if (L.Name == "")
{
ServerInstance->Log(DEFAULT,"Invalid configuration, link tag without a name!");
}
else if (!L.Port)
{
ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', no port specified!",L.Name.c_str());
}
}
LinkBlocks.push_back(L);
ServerInstance->Log(DEBUG,"m_spanningtree: Read server %s with host %s:%d",L.Name.c_str(),L.IPAddr.c_str(),L.Port);
}
else
{
if (L.IPAddr == "")
{
ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', IP address not defined!",L.Name.c_str());
}
else if (L.RecvPass == "")
{
ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', recvpass not defined!",L.Name.c_str());
}
else if (L.SendPass == "")
{
ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', sendpass not defined!",L.Name.c_str());
}
else if (L.Name == "")
{
ServerInstance->Log(DEFAULT,"Invalid configuration, link tag without a name!");
}
else if (!L.Port)
{
ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', no port specified!",L.Name.c_str());
}
ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', link tag has the same server name as the local server!",L.Name.c_str());
}
}
DELETE(Conf);