From 82243d9beb827fca5708efe9e047ff2fec4bfe8c Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 6 Oct 2006 09:09:27 +0000 Subject: Tidy up strlens which are not required git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5428 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_sethost.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/modules/m_sethost.cpp') diff --git a/src/modules/m_sethost.cpp b/src/modules/m_sethost.cpp index 3ec9fc4ca..678786757 100644 --- a/src/modules/m_sethost.cpp +++ b/src/modules/m_sethost.cpp @@ -40,22 +40,23 @@ class cmd_sethost : public command_t CmdResult Handle (const char** parameters, int pcnt, userrec *user) { - if (strlen(parameters[0]) > 64) + size_t len = 0; + for (const char* x = parameters[0]; *x; x++, len++) { - user->WriteServ("NOTICE %s :*** SETHOST: Host too long",user->nick); - return CMD_FAILURE; - } - for (unsigned int x = 0; x < strlen(parameters[0]); x++) - { - if (((tolower(parameters[0][x]) < 'a') || (tolower(parameters[0][x]) > 'z')) && (parameters[0][x] != '.')) + if (((tolower(*x) < 'a') || (tolower(*x) > 'z')) && (*x != '.')) { - if (((parameters[0][x] < '0') || (parameters[0][x]> '9')) && (parameters[0][x] != '-')) + if (((*x < '0') || (*x> '9')) && (*x != '-')) { user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname"); return CMD_FAILURE; } } } + if (len > 64) + { + user->WriteServ("NOTICE %s :*** SETHOST: Host too long",user->nick); + return CMD_FAILURE; + } if (user->ChangeDisplayedHost(parameters[0])) { ServerInstance->WriteOpers(std::string(user->nick)+" used SETHOST to change their displayed host to "+user->dhost); -- cgit v1.3.1-10-gc9f91