]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_chgident.cpp
When a server sends a SERVER command with <5 params, dont just close the connection...
[user/henk/code/inspircd.git] / src / modules / m_chgident.cpp
index 21107f1245116c02f95f6c92d4a98f30db4cdad5..ee6f6e5318bcee194429357cfec7b7a382a98427 100644 (file)
@@ -12,8 +12,6 @@
  */
 
 #include "inspircd.h"
-#include "users.h"
-#include "modules.h"
 
 /* $ModDesc: Provides support for the CHGIDENT command */
 
@@ -26,6 +24,7 @@ class cmd_chgident : public command_t
        {
                this->source = "m_chgident.so";
                syntax = "<nick> <newident>";
+               TRANSLATE3(TR_NICK, TR_TEXT, TR_END);
        }
        
        CmdResult Handle(const char** parameters, int pcnt, userrec *user)
@@ -38,9 +37,21 @@ class cmd_chgident : public command_t
                        return CMD_FAILURE;
                }
 
-               if(!ServerInstance->IsIdent(parameters[1]))
+               if (!*parameters[1])
                {
-                       user->WriteServ("NOTICE %s :*** Invalid characters in ident", user->nick);
+                       user->WriteServ("NOTICE %s :*** CHGIDENT: Ident must be specified", user->nick);
+                       return CMD_FAILURE;
+               }
+               
+               if (strlen(parameters[1]) > IDENTMAX)
+               {
+                       user->WriteServ("NOTICE %s :*** CHGIDENT: Ident is too long", user->nick);
+                       return CMD_FAILURE;
+               }
+               
+               if (!ServerInstance->IsIdent(parameters[1]))
+               {
+                       user->WriteServ("NOTICE %s :*** CHGIDENT: Invalid characters in ident", user->nick);
                        return CMD_FAILURE;
                }
 
@@ -71,10 +82,10 @@ public:
        
        virtual Version GetVersion()
        {
-               return Version(1,1,0,0,VF_VENDOR,API_VERSION);
+               return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
        }
        
 };
 
-MODULE_INIT(ModuleChgIdent);
+MODULE_INIT(ModuleChgIdent)