]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
Added some missing parameter checking in m_swhois
[user/henk/code/inspircd.git] / src / users.cpp
index 7e0851f59abf0c6e3c50c9dfb6121d18c913aae0..d83788566acac1afb47976d7875f5bbe25830b28 100644 (file)
@@ -198,7 +198,7 @@ void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl,
        else if ((this->fwd) && (ServerInstance->SE->GetRef(this->bound_fd) == this->bound_user))
        {
                /* Both lookups completed */
-               std::string result2 = "0::ffff:";
+               std::string result2("0::ffff:");
                result2.append(result);
                if (this->bound_user->GetIPString() == result || this->bound_user->GetIPString() == result2)
                {
@@ -210,7 +210,7 @@ void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl,
                                {
                                        /* Hostnames starting with : are not a good thing (tm) */
                                        if (*(hostname.c_str()) == ':')
-                                               hostname = "0" + hostname;
+                                               hostname.insert(0, "0");
 
                                        this->bound_user->WriteServ("NOTICE Auth :*** Found your hostname (%s)%s", hostname.c_str(), (cached ? " -- cached" : ""));
                                        this->bound_user->dns_done = true;
@@ -1015,11 +1015,6 @@ void userrec::CheckClass()
                userrec::QuitUser(ServerInstance, this, "Unauthorised connection");
                return;
        }
-       else if ((!a->GetPass().empty()) && (!this->haspassed))
-       {
-               userrec::QuitUser(ServerInstance, this, "Invalid password");
-               return;
-       }
        else if ((a->GetMaxLocal()) && (this->LocalCloneCount() > a->GetMaxLocal()))
        {
                userrec::QuitUser(ServerInstance, this, "No more connections allowed from your host via this connect class (local)");
@@ -1046,7 +1041,16 @@ void userrec::FullConnect()
         * Don't remove this! -- w00t
         */
        this->CheckClass();
-
+       
+       /* Check the password, if one is required by the user's connect class.
+        * This CANNOT be in CheckClass(), because that is called prior to PASS as well!
+        */
+       if ((!this->GetClass()->GetPass().empty()) && (!this->haspassed))
+       {
+               userrec::QuitUser(ServerInstance, this, "Invalid password");
+               return;
+       }
+       
        if (!this->exempt)
        {
                GLine* r = ServerInstance->XLines->matches_gline(this);
@@ -1177,10 +1181,7 @@ bool userrec::ForceNickChange(const char* newnick)
 
                if (this->registered == REG_ALL)
                {
-                       const char* pars[1];
-                       pars[0] = newnick;
-                       std::string cmd = "NICK";
-                       return (ServerInstance->Parser->CallHandler(cmd, pars, 1, this) == CMD_SUCCESS);
+                       return (ServerInstance->Parser->CallHandler("NICK", &newnick, 1, this) == CMD_SUCCESS);
                }
                return false;
        }
@@ -1374,6 +1375,9 @@ void userrec::Write(std::string text)
        {
                try
                {
+                       /* XXX: The lack of buffering here is NOT a bug, modules implementing this interface have to
+                        * implement their own buffering mechanisms
+                        */
                        ServerInstance->Config->GetIOHook(this->GetPort())->OnRawSocketWrite(this->fd, text.data(), text.length());
                }
                catch (CoreException& modexcept)
@@ -1616,7 +1620,8 @@ void userrec::WriteWallOps(const std::string &text)
        if (!IS_OPER(this) && IS_LOCAL(this))
                return;
 
-       std::string wallop = "WALLOPS :" + text;
+       std::string wallop("WALLOPS :");
+       wallop.append(text);
 
        for (std::vector<userrec*>::const_iterator i = ServerInstance->local_users.begin(); i != ServerInstance->local_users.end(); i++)
        {