summaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-05-25 17:30:43 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-05-25 17:30:43 +0000
commit7d7250484c352c13830e63ae41ee8faae40a9bd5 (patch)
tree0fdf4941b4d72469a18eec97506f06f6e94e86e9 /src/commands
parente7b837ec5f120f928a0dc321fa918bdd01ab0c02 (diff)
First phase of conversion to dynamic limits on all the lengths, configured via the <limits> tag
(the tag isnt there yet, these all just run on defaults in the class constructor) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9802 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/cmd_away.cpp2
-rw-r--r--src/commands/cmd_join.cpp4
-rw-r--r--src/commands/cmd_kick.cpp8
-rw-r--r--src/commands/cmd_kill.cpp6
-rw-r--r--src/commands/cmd_nick.cpp20
-rw-r--r--src/commands/cmd_notice.cpp5
-rw-r--r--src/commands/cmd_oper.cpp2
-rw-r--r--src/commands/cmd_privmsg.cpp5
-rw-r--r--src/commands/cmd_stats.cpp10
-rw-r--r--src/commands/cmd_topic.cpp8
-rw-r--r--src/commands/cmd_user.cpp6
11 files changed, 35 insertions, 41 deletions
diff --git a/src/commands/cmd_away.cpp b/src/commands/cmd_away.cpp
index 7fac7ae6d..6dccf9759 100644
--- a/src/commands/cmd_away.cpp
+++ b/src/commands/cmd_away.cpp
@@ -33,7 +33,7 @@ CmdResult CommandAway::Handle (const std::vector<std::string>& parameters, User
return CMD_FAILURE;
user->awaytime = ServerInstance->Time();
- user->awaymsg.assign(parameters[0], 0, MAXAWAY);
+ user->awaymsg.assign(parameters[0], 0, ServerInstance->Config->Limits.MaxAway);
user->WriteNumeric(306, "%s :You have been marked as being away",user->nick.c_str());
}
diff --git a/src/commands/cmd_join.cpp b/src/commands/cmd_join.cpp
index b27007507..c19e7c015 100644
--- a/src/commands/cmd_join.cpp
+++ b/src/commands/cmd_join.cpp
@@ -28,7 +28,7 @@ CmdResult CommandJoin::Handle (const std::vector<std::string>& parameters, User
if (ServerInstance->Parser->LoopCall(user, this, parameters, 0, 1))
return CMD_SUCCESS;
- if (ServerInstance->IsChannel(parameters[0].c_str()))
+ if (ServerInstance->IsChannel(parameters[0].c_str(), ServerInstance->Config->Limits.ChanMax))
{
Channel::JoinUser(ServerInstance, user, parameters[0].c_str(), false, parameters[1].c_str(), false);
return CMD_SUCCESS;
@@ -39,7 +39,7 @@ CmdResult CommandJoin::Handle (const std::vector<std::string>& parameters, User
if (ServerInstance->Parser->LoopCall(user, this, parameters, 0))
return CMD_SUCCESS;
- if (ServerInstance->IsChannel(parameters[0].c_str()))
+ if (ServerInstance->IsChannel(parameters[0].c_str(), ServerInstance->Config->Limits.ChanMax))
{
Channel::JoinUser(ServerInstance, user, parameters[0].c_str(), false, "", false);
return CMD_SUCCESS;
diff --git a/src/commands/cmd_kick.cpp b/src/commands/cmd_kick.cpp
index 174800cf5..a0ff5d1c3 100644
--- a/src/commands/cmd_kick.cpp
+++ b/src/commands/cmd_kick.cpp
@@ -23,7 +23,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
*/
CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User *user)
{
- char reason[MAXKICK];
+ std::string reason;
Channel* c = ServerInstance->FindChan(parameters[0]);
User* u = ServerInstance->FindNick(parameters[1]);
@@ -44,14 +44,14 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User
if (parameters.size() > 2)
{
- strlcpy(reason, parameters[2].c_str(), MAXKICK - 1);
+ reason.assign(parameters[2], 0, ServerInstance->Config->Limits.MaxKick);
}
else
{
- strlcpy(reason, user->nick.c_str(), MAXKICK - 1);
+ reason.assign(user->nick, 0, ServerInstance->Config->Limits.MaxKick);
}
- if (!c->KickUser(user, u, reason))
+ if (!c->KickUser(user, u, reason.c_str()))
/* Nobody left here, delete the Channel */
delete c;
diff --git a/src/commands/cmd_kill.cpp b/src/commands/cmd_kill.cpp
index f656c5701..02e80b4f2 100644
--- a/src/commands/cmd_kill.cpp
+++ b/src/commands/cmd_kill.cpp
@@ -54,18 +54,18 @@ CmdResult CommandKill::Handle (const std::vector<std::string>& parameters, User
if (*ServerInstance->Config->HideKillsServer)
{
// hidekills is on, use it
- snprintf(killreason, MAXQUIT, "Killed (%s (%s))", ServerInstance->Config->HideKillsServer, parameters[1].c_str());
+ snprintf(killreason, ServerInstance->Config->Limits.MaxQuit, "Killed (%s (%s))", ServerInstance->Config->HideKillsServer, parameters[1].c_str());
}
else
{
// hidekills is off, do nothing
- snprintf(killreason, MAXQUIT, "Killed (%s (%s))", user->nick.c_str(), parameters[1].c_str());
+ snprintf(killreason, ServerInstance->Config->Limits.MaxQuit, "Killed (%s (%s))", user->nick.c_str(), parameters[1].c_str());
}
}
else
{
/* Leave it alone, remote server has already formatted it */
- strlcpy(killreason, parameters[1].c_str(), MAXQUIT);
+ strlcpy(killreason, parameters[1].c_str(), ServerInstance->Config->Limits.MaxQuit);
}
/*
diff --git a/src/commands/cmd_nick.cpp b/src/commands/cmd_nick.cpp
index 0391323dc..0eb55ccfe 100644
--- a/src/commands/cmd_nick.cpp
+++ b/src/commands/cmd_nick.cpp
@@ -27,7 +27,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
*/
CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User *user)
{
- char oldnick[NICKMAX];
+ std::string oldnick;
if (parameters[0].empty())
{
@@ -36,7 +36,7 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User
return CMD_FAILURE;
}
- if (((!ServerInstance->IsNick(parameters[0].c_str()))) && (IS_LOCAL(user)))
+ if (((!ServerInstance->IsNick(parameters[0].c_str(), ServerInstance->Config->Limits.NickMax))) && (IS_LOCAL(user)))
{
if (!allowinvalid)
{
@@ -59,11 +59,9 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User
if (assign(user->nick) == parameters[0])
{
- ServerInstance->Logs->Log("nick", DEBUG, "Change to same nick '%s' %d '%s' '%d'", user->nick.c_str(), user->nick.length(), parameters[0].c_str(), parameters[0].length());
/* If its exactly the same, even case, dont do anything. */
if (parameters[0] == user->nick)
{
- ServerInstance->Logs->Log("nick", DEBUG, "Not even a case change");
return CMD_SUCCESS;
}
@@ -71,14 +69,14 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User
* able to do silly things like this even though the RFC says
* the nick AAA is the same as the nick aaa.
*/
- strlcpy(oldnick, user->nick.c_str(), NICKMAX - 1);
+ oldnick.assign(user->nick, 0, ServerInstance->Config->Limits.NickMax);
int MOD_RESULT = 0;
- FOREACH_RESULT(I_OnUserPreNick,OnUserPreNick(user,parameters[0].c_str()));
+ FOREACH_RESULT(I_OnUserPreNick,OnUserPreNick(user,parameters[0]));
if (MOD_RESULT)
return CMD_FAILURE;
if (user->registered == REG_ALL)
user->WriteCommon("NICK %s",parameters[0].c_str());
- user->nick.assign(parameters[0], 0, NICKMAX - 1);
+ user->nick.assign(parameters[0], 0, ServerInstance->Config->Limits.NickMax);
user->InvalidateCache();
FOREACH_MOD(I_OnUserPostNick,OnUserPostNick(user,oldnick));
return CMD_SUCCESS;
@@ -122,7 +120,7 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User
InUse->WriteTo(InUse, "NICK %s", InUse->uuid.c_str());
InUse->WriteNumeric(433, "%s %s :Nickname overruled.", InUse->nick.c_str(), InUse->nick.c_str());
InUse->UpdateNickHash(InUse->uuid.c_str());
- InUse->nick.assign(InUse->uuid, 0, NICKMAX - 1);
+ InUse->nick.assign(InUse->uuid, 0, ServerInstance->Config->Limits.NickMax);
InUse->InvalidateCache();
InUse->registered &= ~REG_NICK;
}
@@ -145,7 +143,7 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User
if (user->registered == REG_ALL)
user->WriteCommon("NICK %s", parameters[0].c_str());
- strlcpy(oldnick, user->nick.c_str(), NICKMAX - 1);
+ oldnick.assign(user->nick, 0, ServerInstance->Config->Limits.NickMax);
/* change the nick of the user in the users_hash */
user = user->UpdateNickHash(parameters[0].c_str());
@@ -154,7 +152,7 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User
if (!user)
return CMD_FAILURE;
- user->nick.assign(parameters[0], 0, NICKMAX - 1);
+ user->nick.assign(parameters[0], 0, ServerInstance->Config->Limits.NickMax);
user->InvalidateCache();
/* Update display nicks */
@@ -181,7 +179,7 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User
if (user->registered == REG_ALL)
{
user->IncreasePenalty(10);
- FOREACH_MOD(I_OnUserPostNick,OnUserPostNick(user,oldnick));
+ FOREACH_MOD(I_OnUserPostNick,OnUserPostNick(user, oldnick));
}
return CMD_SUCCESS;
diff --git a/src/commands/cmd_notice.cpp b/src/commands/cmd_notice.cpp
index 5086f3f4f..9cf4800a4 100644
--- a/src/commands/cmd_notice.cpp
+++ b/src/commands/cmd_notice.cpp
@@ -130,8 +130,9 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use
if (targetserver)
{
- char nickonly[NICKMAX+1];
- strlcpy(nickonly, destnick, targetserver - destnick + 1);
+ std::string nickonly;
+
+ nickonly.assign(destnick, 0, targetserver - destnick + 1);
dest = ServerInstance->FindNickOnly(nickonly);
if (dest && strcasecmp(dest->server, targetserver + 1))
{
diff --git a/src/commands/cmd_oper.cpp b/src/commands/cmd_oper.cpp
index 1ce7dc49d..97134f038 100644
--- a/src/commands/cmd_oper.cpp
+++ b/src/commands/cmd_oper.cpp
@@ -80,7 +80,7 @@ CmdResult CommandOper::Handle (const std::vector<std::string>& parameters, User
if (!strcmp(TypeName,OperType))
{
/* found this oper's opertype */
- if (!ServerInstance->IsNick(TypeName))
+ if (!ServerInstance->IsNick(TypeName, ServerInstance->Config->Limits.NickMax))
{
user->WriteNumeric(491, "%s :Invalid oper type (oper types must follow the same syntax as nicknames)",user->nick.c_str());
ServerInstance->SNO->WriteToSnoMask('o',"CONFIGURATION ERROR! Oper type '%s' contains invalid characters",OperType);
diff --git a/src/commands/cmd_privmsg.cpp b/src/commands/cmd_privmsg.cpp
index 842635ae2..0086bb72d 100644
--- a/src/commands/cmd_privmsg.cpp
+++ b/src/commands/cmd_privmsg.cpp
@@ -132,8 +132,9 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us
if (targetserver)
{
- char nickonly[NICKMAX+1];
- strlcpy(nickonly, destnick, targetserver - destnick + 1);
+ std::string nickonly;
+
+ nickonly.assign(destnick, 0, targetserver - destnick + 1);
dest = ServerInstance->FindNickOnly(nickonly);
if (dest && strcasecmp(dest->server, targetserver + 1))
{
diff --git a/src/commands/cmd_stats.cpp b/src/commands/cmd_stats.cpp
index 9da5f1aeb..fafa97581 100644
--- a/src/commands/cmd_stats.cpp
+++ b/src/commands/cmd_stats.cpp
@@ -264,10 +264,7 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str
for (std::vector<User*>::iterator n = ServerInstance->Users->local_users.begin(); n != ServerInstance->Users->local_users.end(); n++)
{
User* i = *n;
- if (ServerInstance->IsNick(i->nick.c_str()))
- {
- results.push_back(sn+" 211 "+user->nick+" "+i->nick+"["+i->ident+"@"+i->dhost+"] "+ConvToStr(i->sendq.length())+" "+ConvToStr(i->cmds_out)+" "+ConvToStr(i->bytes_out)+" "+ConvToStr(i->cmds_in)+" "+ConvToStr(i->bytes_in)+" "+ConvToStr(ServerInstance->Time() - i->age));
- }
+ results.push_back(sn+" 211 "+user->nick+" "+i->nick+"["+i->ident+"@"+i->dhost+"] "+ConvToStr(i->sendq.length())+" "+ConvToStr(i->cmds_out)+" "+ConvToStr(i->bytes_out)+" "+ConvToStr(i->cmds_in)+" "+ConvToStr(i->bytes_in)+" "+ConvToStr(ServerInstance->Time() - i->age));
}
break;
@@ -277,10 +274,7 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str
for (std::vector<User*>::iterator n = ServerInstance->Users->local_users.begin(); n != ServerInstance->Users->local_users.end(); n++)
{
User* i = *n;
- if (ServerInstance->IsNick(i->nick.c_str()))
- {
- results.push_back(sn+" 211 "+user->nick+" "+i->nick+"["+i->ident+"@"+i->GetIPString()+"] "+ConvToStr(i->sendq.length())+" "+ConvToStr(i->cmds_out)+" "+ConvToStr(i->bytes_out)+" "+ConvToStr(i->cmds_in)+" "+ConvToStr(i->bytes_in)+" "+ConvToStr(ServerInstance->Time() - i->age));
- }
+ results.push_back(sn+" 211 "+user->nick+" "+i->nick+"["+i->ident+"@"+i->GetIPString()+"] "+ConvToStr(i->sendq.length())+" "+ConvToStr(i->cmds_out)+" "+ConvToStr(i->bytes_out)+" "+ConvToStr(i->cmds_in)+" "+ConvToStr(i->bytes_in)+" "+ConvToStr(ServerInstance->Time() - i->age));
}
break;
diff --git a/src/commands/cmd_topic.cpp b/src/commands/cmd_topic.cpp
index e723a50c9..0e1a115da 100644
--- a/src/commands/cmd_topic.cpp
+++ b/src/commands/cmd_topic.cpp
@@ -70,7 +70,7 @@ CmdResult CommandTopic::Handle (const std::vector<std::string>& parameters, User
}
}
- char topic[MAXTOPIC];
+ std::string topic;
if (IS_LOCAL(user))
{
@@ -79,17 +79,17 @@ CmdResult CommandTopic::Handle (const std::vector<std::string>& parameters, User
*/
int MOD_RESULT = 0;
- strlcpy(topic, parameters[1].c_str(), MAXTOPIC);
+ topic.assign(parameters[1], 0, ServerInstance->Config->Limits.MaxTopic);
FOREACH_RESULT(I_OnLocalTopicChange,OnLocalTopicChange(user,Ptr,topic));
if (MOD_RESULT)
return CMD_FAILURE;
- Ptr->topic.assign(topic, 0, MAXTOPIC);
+ Ptr->topic.assign(topic, 0, ServerInstance->Config->Limits.MaxTopic);
}
else
{
/* Sneaky shortcut, one string copy for a remote topic */
- Ptr->topic.assign(parameters[1], 0, MAXTOPIC);
+ Ptr->topic.assign(parameters[1], 0, ServerInstance->Config->Limits.MaxTopic);
}
Ptr->setby.assign(ServerInstance->Config->FullHostInTopic ?
diff --git a/src/commands/cmd_user.cpp b/src/commands/cmd_user.cpp
index 1acd901f9..7bc9307f6 100644
--- a/src/commands/cmd_user.cpp
+++ b/src/commands/cmd_user.cpp
@@ -40,14 +40,14 @@ CmdResult CommandUser::Handle (const std::vector<std::string>& parameters, User
* ~ character, and +1 for null termination, therefore we can safely use up to
* IDENTMAX here.
*/
- user->ident.assign(parameters[0], 0, IDENTMAX);
- user->fullname.assign(parameters[3].empty() ? std::string("No info") : parameters[3], 0, MAXGECOS);
+ user->ident.assign(parameters[0], 0, ServerInstance->Config->Limits.IdentMax);
+ user->fullname.assign(parameters[3].empty() ? std::string("No info") : parameters[3], 0, ServerInstance->Config->Limits.MaxGecos);
user->registered = (user->registered | REG_USER);
}
}
else
{
- user->WriteNumeric(462, "%s :You may not reregister",user->nick.c_str());
+ user->WriteNumeric(462, "%s :You may not reregister", user->nick.c_str());
return CMD_FAILURE;
}