X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_chghost.cpp;h=82a94fadc82b581700952a4e90c37ae403bf1708;hb=fea1a27cb96a114f698eedcf90401b78406108fb;hp=0dd250f1892ca08832dff1b02365f55d7ec9f092;hpb=0baef3051c3d85c36f1a4a287ff65d59e8dd1a59;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_chghost.cpp b/src/modules/m_chghost.cpp index 0dd250f18..82a94fadc 100644 --- a/src/modules/m_chghost.cpp +++ b/src/modules/m_chghost.cpp @@ -21,38 +21,41 @@ using namespace std; #include "users.h" #include "channels.h" #include "modules.h" +#include "helperfuncs.h" /* $ModDesc: Provides support for the CHGHOST command */ -Server *Srv; - +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"; + syntax = " "; + } - void Handle(char **parameters, int pcnt, userrec *user) + void Handle(const 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++) + const 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"); + user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname"); return; } } - } + } + if ((parameters[1] - x) > 63) + { + user->WriteServ("NOTICE %s :*** CHGHOST: Host too long",user->nick); + return; + } userrec* dest = Srv->FindNick(std::string(parameters[0])); if (dest) {