summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_httpd.cpp5
-rw-r--r--src/modules/m_sethost.cpp17
-rw-r--r--src/modules/m_setident.cpp12
3 files changed, 19 insertions, 15 deletions
diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp
index 6df26e9c0..189a80b89 100644
--- a/src/modules/m_httpd.cpp
+++ b/src/modules/m_httpd.cpp
@@ -72,7 +72,6 @@ class HttpSocket : public InspSocket
std::string uri;
std::string http_version;
unsigned int postsize;
- unsigned int amount;
HTTPTimeout* Timeout;
public:
@@ -254,7 +253,6 @@ class HttpSocket : public InspSocket
{
/* Do we need to fetch postdata? */
postdata = "";
- amount = 0;
InternalState = HTTP_SERVE_RECV_POSTDATA;
std::string header_item;
while (headers >> header_item)
@@ -286,9 +284,8 @@ class HttpSocket : public InspSocket
else if (InternalState == HTTP_SERVE_RECV_POSTDATA)
{
/* Add postdata, once we have it all, send the event */
- amount += strlen(data);
postdata.append(data);
- if (amount >= postsize)
+ if (postdata.length() >= postsize)
ServeData();
}
else
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);
diff --git a/src/modules/m_setident.cpp b/src/modules/m_setident.cpp
index 2bcdceeb1..d1f67bb14 100644
--- a/src/modules/m_setident.cpp
+++ b/src/modules/m_setident.cpp
@@ -15,14 +15,20 @@ class cmd_setident : public command_t
CmdResult Handle(const char** parameters, int pcnt, userrec *user)
{
- for(unsigned int x = 0; x < strlen(parameters[0]); x++)
+ size_t len = 0;
+ for(const char* x = parameters[0]; *x; x++, len++)
{
- if(((parameters[0][x] >= 'A') && (parameters[0][x] <= '}')) || strchr(".-0123456789", parameters[0][x]))
+ if(((*x >= 'A') && (*x <= '}')) || strchr(".-0123456789", *x))
continue;
-
+
user->WriteServ("NOTICE %s :*** Invalid characters in ident", user->nick);
return CMD_FAILURE;
}
+ if (len > IDENTMAX)
+ {
+ user->WriteServ("NOTICE %s :*** Ident is too long", user->nick);
+ return CMD_FAILURE;
+ }
user->ChangeIdent(parameters[0]);
ServerInstance->WriteOpers("%s used SETIDENT to change their ident to '%s'", user->nick, user->ident);