diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-03-09 18:09:19 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-03-09 18:09:19 +0000 |
commit | 797c8ac76967a1b0a3fc61b55cf4d3903f019f9a (patch) | |
tree | 5e0f6bd7c942ca563fb1a39db90381079f7c55e7 /src | |
parent | 2b8c7fada77a0b5a5ddcf4947b4e4d3bdb9ccdc7 (diff) |
Improved to avoid strlen
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3599 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/m_chghost.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/modules/m_chghost.cpp b/src/modules/m_chghost.cpp index 8cfc515cd..d77ddf515 100644 --- a/src/modules/m_chghost.cpp +++ b/src/modules/m_chghost.cpp @@ -37,22 +37,24 @@ class cmd_chghost : public command_t 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) { |