summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-12 02:50:14 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-12 02:50:14 +0000
commit7ba6c9f001f8093f4174659531a7be2825d28ae8 (patch)
tree90599ae184d3e0ce4a71b544222a33d2abc42ea2
parentdb8273d4e705a3127a654a77a22dc50482e21584 (diff)
Fix automatic SID generation when generated value is less than 100
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11850 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/configreader.cpp6
-rw-r--r--src/inspircd.cpp7
2 files changed, 7 insertions, 6 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 05171ea60..22d4e36dc 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -410,11 +410,11 @@ static bool ValidateSID(ServerConfig* conf, const char*, const char*, ValueItem
{
ServerInstance->Logs->Log("CONFIG",DEFAULT,"Validating server id");
- const char *sid = data.GetString();
+ const std::string& sid = data.GetValue();
- if (*sid && !ServerInstance->IsSID(sid))
+ if (!ServerInstance->IsSID(sid))
{
- throw CoreException(std::string(sid) + " is not a valid server ID. A server ID must be 3 characters long, with the first character a digit and the next two characters a digit or letter.");
+ throw CoreException(sid + " is not a valid server ID. A server ID must be 3 characters long, with the first character a digit and the next two characters a digit or letter.");
}
conf->sid = sid;
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 857009744..7e9d56734 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -568,15 +568,16 @@ InspIRCd::InspIRCd(int argc, char** argv) :
if (Config->sid.empty())
{
// Generate one
- size_t sid = 0;
+ int sid = 0;
+ char sidstr[4];
for (const char* x = Config->ServerName.c_str(); *x; ++x)
sid = 5 * sid + *x;
for (const char* y = Config->ServerDesc.c_str(); *y; ++y)
sid = 5 * sid + *y;
- sid = sid % 999;
+ sprintf(sidstr, "%03d", sid % 1000);
- Config->sid = ConvToStr(sid);
+ Config->sid = sidstr;
}
/* set up fake client again this time with the correct uid */