summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/configreader.cpp8
-rw-r--r--src/helperfuncs.cpp10
-rw-r--r--src/modules/m_spanningtree/treesocket2.cpp6
-rw-r--r--src/modules/m_spanningtree/utils.cpp12
-rw-r--r--src/modules/m_spanningtree/utils.h5
5 files changed, 21 insertions, 20 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 23c3fd925..d854edfaf 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -478,7 +478,13 @@ bool ValidateInvite(ServerConfig* conf, const char*, const char*, ValueItem &dat
bool ValidateSID(ServerConfig* conf, const char*, const char*, ValueItem &data)
{
-// std::string sid = data.GetString();
+ const char *sid = data.GetString();
+
+ if (*sid && !conf->GetInstance()->IsSID(sid))
+ {
+ throw CoreException(std::string(sid) + " is not a valid server ID.");
+ }
+
return true;
}
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index 309267c38..40b2d7d90 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -506,6 +506,16 @@ bool IsIdentHandler::Call(const char* n)
return true;
}
+bool InspIRCd::IsSID(const std::string &str)
+{
+ /* Returns true if the string given is exactly 3 characters long,
+ * starts with a digit, and the other two characters are A-Z or digits
+ */
+ return ((str.length() == 3) && isdigit(str[0]) &&
+ ((str[1] >= 'A' && str[1] <= 'Z') || isdigit(str[1])) &&
+ ((str[2] >= 'A' && str[2] <= 'Z') || isdigit(str[2])));
+}
+
/* open the proper logfile */
bool InspIRCd::OpenLog(char**, int)
{
diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp
index 8f0ee0f17..e5d25dc50 100644
--- a/src/modules/m_spanningtree/treesocket2.cpp
+++ b/src/modules/m_spanningtree/treesocket2.cpp
@@ -818,7 +818,7 @@ bool TreeSocket::RemoteServer(const std::string &prefix, std::deque<std::string>
this->SendError("Protocol error - Introduced remote server from unknown server "+prefix);
return false;
}
- if (!Utils->IsSID(sid))
+ if (!this->Instance->IsSID(sid))
{
this->SendError("Invalid format server ID: "+sid+"!");
return false;
@@ -897,7 +897,7 @@ bool TreeSocket::Outbound_Reply_Server(std::deque<std::string> &params)
return false;
}
- if (!Utils->IsSID(sid))
+ if (!this->Instance->IsSID(sid))
{
this->SendError("Invalid format server ID: "+sid+"!");
return false;
@@ -974,7 +974,7 @@ bool TreeSocket::Inbound_Server(std::deque<std::string> &params)
return false;
}
- if (!Utils->IsSID(sid))
+ if (!this->Instance->IsSID(sid))
{
this->SendError("Invalid format server ID: "+sid+"!");
return false;
diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp
index 32580cd97..4e0193727 100644
--- a/src/modules/m_spanningtree/utils.cpp
+++ b/src/modules/m_spanningtree/utils.cpp
@@ -29,16 +29,6 @@
/* $ModDep: m_spanningtree/timesynctimer.h m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h */
-bool SpanningTreeUtilities::IsSID(const std::string &str)
-{
- /* Returns true if the string given is exactly 3 characters long,
- * starts with a digit, and the other two characters are A-Z or digits
- */
- return ((str.length() == 3) && isdigit(str[0]) &&
- ((str[1] >= 'A' && str[1] <= 'Z') || isdigit(str[1])) &&
- ((str[2] >= 'A' && str[2] <= 'Z') || isdigit(str[2])));
-}
-
/** Yay for fast searches!
* This is hundreds of times faster than recursion
* or even scanning a linked list, especially when
@@ -47,7 +37,7 @@ bool SpanningTreeUtilities::IsSID(const std::string &str)
*/
TreeServer* SpanningTreeUtilities::FindServer(const std::string &ServerName)
{
- if (IsSID(ServerName))
+ if (this->ServerInstance->IsSID(ServerName))
return this->FindServerID(ServerName);
server_hash::iterator iter = serverlist.find(ServerName.c_str());
diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h
index 6fb8b3e6e..f79b5280e 100644
--- a/src/modules/m_spanningtree/utils.h
+++ b/src/modules/m_spanningtree/utils.h
@@ -190,11 +190,6 @@ class SpanningTreeUtilities
void AddBurstingServer(const std::string &ServerName, TreeSocket* s);
void DelBurstingServer(TreeSocket* s);
-
- /** Return true if str looks like a server ID
- * @param string to check against
- */
- bool IsSID(const std::string &str);
};
#endif