summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/modules/m_chghost.cpp12
-rw-r--r--src/modules/m_sethost.cpp11
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]));
}