From 797c8ac76967a1b0a3fc61b55cf4d3903f019f9a Mon Sep 17 00:00:00 2001 From: brain Date: Thu, 9 Mar 2006 18:09:19 +0000 Subject: Improved to avoid strlen git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3599 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_chghost.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/modules') 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) { -- cgit v1.2.3