diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2004-04-07 22:05:15 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2004-04-07 22:05:15 +0000 |
commit | d46b8db930e1cd71751b76f9dd0451fddfda6c6d (patch) | |
tree | 10b7756a6374551b6b128b1af53df96dc9734ac4 /src/modules | |
parent | 4207f91ab44561f41eaadf75d528d669ea523eea (diff) |
Added a sanity check on the hostnames being set before actually setting them
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@433 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_chghost.cpp | 12 | ||||
-rw-r--r-- | src/modules/m_sethost.cpp | 11 |
2 files changed, 22 insertions, 1 deletions
diff --git a/src/modules/m_chghost.cpp b/src/modules/m_chghost.cpp index 885bee679..7938f8b23 100644 --- a/src/modules/m_chghost.cpp +++ b/src/modules/m_chghost.cpp @@ -20,7 +20,17 @@ Server *Srv; void handle_chghost(char **parameters, int pcnt, userrec *user) { - userrec* dest = Srv->FindNick(std::string(parameters[0])); + for (int x = 0; x < strlen(parameters[1]); x++) + { + if (((tolower(parameters[1][x]) < 'a') || (tolower(parameters[1][x]) > 'z')) && (parameters[1][x] != '.')) + { + if (((parameters[1][x] < '0') || (parameters[1][x]> '9')) && (parameters[1][x] != '-')) + { + Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname"); + return; + } + } + } userrec* dest = Srv->FindNick(std::string(parameters[0])); if (dest) { strncpy(dest->dhost,parameters[1],127); diff --git a/src/modules/m_sethost.cpp b/src/modules/m_sethost.cpp index 774d5a00c..d1aabd004 100644 --- a/src/modules/m_sethost.cpp +++ b/src/modules/m_sethost.cpp @@ -21,6 +21,17 @@ Server *Srv; void handle_sethost(char **parameters, int pcnt, userrec *user) { + for (int x = 0; x < strlen(parameters[0]); x++) + { + if (((tolower(parameters[0][x]) < 'a') || (tolower(parameters[0][x]) > 'z')) && (parameters[0][x] != '.')) + { + if (((parameters[0][x] < '0') || (parameters[0][x]> '9')) && (parameters[0][x] != '-')) + { + Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname"); + return; + } + } + } strncpy(user->dhost,parameters[0],127); Srv->SendOpers(std::string(user->nick)+" used SETHOST to change their displayed host to "+std::string(parameters[1])); } |