]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_chghost.cpp
XHTML 1.1 spec validation and charset
[user/henk/code/inspircd.git] / src / modules / m_chghost.cpp
index 8cfc515cd77032ca8b8739e216c4bd356d972396..1a547f54883bce59db5bf3f3cf0511cf39f01dce 100644 (file)
@@ -30,29 +30,31 @@ static Server *Srv;
 class cmd_chghost : public command_t
 {
  public:
-         cmd_chghost () : command_t("CHGHOST",'o',2)
-        {
-                this->source = "m_chghost.so";
-        }
+       cmd_chghost () : command_t("CHGHOST",'o',2)
+       {
+               this->source = "m_chghost.so";
+       }
         
-        void Handle(char **parameters, int pcnt, userrec *user)
+       void Handle(char **parameters, int pcnt, userrec *user)
        {
-                if (strlen(parameters[1]) > 64)
-                {
-                        WriteServ(user->fd,"NOTICE %s :*** CHGHOST: Host too long",user->nick);
-                       return;
-                }
-               for (unsigned int x = 0; x < strlen(parameters[1]); x++)
+               char * x = parameters[1];
+
+               for (; *x; x++)
                {
-                       if (((tolower(parameters[1][x]) < 'a') || (tolower(parameters[1][x]) > 'z')) && (parameters[1][x] != '.'))
+                       if (((tolower(*x) < 'a') || (tolower(*x) > 'z')) && (*x != '.'))
                        {
-                               if (((parameters[1][x] < '0') || (parameters[1][x]> '9')) && (parameters[1][x] != '-'))
+                               if (((*x < '0') || (*x > '9')) && (*x != '-'))
                                {
                                        Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname");
                                        return;
                                }
                        }
-               }       
+               }
+               if ((parameters[1] - x) > 63)
+               {
+                       WriteServ(user->fd,"NOTICE %s :*** CHGHOST: Host too long",user->nick);
+                       return;
+               }
                userrec* dest = Srv->FindNick(std::string(parameters[0]));
                if (dest)
                {