summaryrefslogtreecommitdiff
path: root/src/modules/m_sethost.cpp
diff options
context:
space:
mode:
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);