]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fix automatic SID generation when generated value is less than 100
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 12 Oct 2009 02:50:14 +0000 (02:50 +0000)
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 12 Oct 2009 02:50:14 +0000 (02:50 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11850 e03df62e-2008-0410-955e-edbf42e46eb7

src/configreader.cpp
src/inspircd.cpp

index 05171ea60d605de4b093ccf0df8ec2d6d57f236f..22d4e36dcc9ea745f2e751ae2d306723c9d47afb 100644 (file)
@@ -410,11 +410,11 @@ static bool ValidateSID(ServerConfig* conf, const char*, const char*, ValueItem
 {
        ServerInstance->Logs->Log("CONFIG",DEFAULT,"Validating server id");
 
 {
        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;
        }
 
        conf->sid = sid;
index 8570097446be710ca3d62e2589f5e0ab5a2bc5f5..7e9d56734fd2269fdfe9b7bb3a63d49b799af0d3 100644 (file)
@@ -568,15 +568,16 @@ InspIRCd::InspIRCd(int argc, char** argv) :
        if (Config->sid.empty())
        {
                // Generate one
        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;
 
                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 */
        }
 
        /* set up fake client again this time with the correct uid */