summaryrefslogtreecommitdiff
path: root/src/modules/m_sethost.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-10-06 09:09:27 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-10-06 09:09:27 +0000
commit82243d9beb827fca5708efe9e047ff2fec4bfe8c (patch)
tree8013da43263aa2d175e906d454d37fe6680b5220 /src/modules/m_sethost.cpp
parentf7fa509637447df624cb0a0332ac2c07d091674c (diff)
Tidy up strlens which are not required
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5428 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_sethost.cpp')
-rw-r--r--src/modules/m_sethost.cpp17
1 files changed, 9 insertions, 8 deletions
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);