From d46b8db930e1cd71751b76f9dd0451fddfda6c6d Mon Sep 17 00:00:00 2001 From: brain Date: Wed, 7 Apr 2004 22:05:15 +0000 Subject: 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 --- src/modules/m_chghost.cpp | 12 +++++++++++- src/modules/m_sethost.cpp | 11 +++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'src') 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])); } -- cgit v1.2.3