summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2010-03-21 19:57:08 +0000
committerAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2010-03-21 19:57:08 +0000
commitfc05827621fe0c623d2fedf9dcb47c17d57bea16 (patch)
tree11a6cc4dedd80802520e454f888c0f1e6cbe08aa
parent04bf65525ab0db8393b89c12c3aeae52b91fe4ac (diff)
Made usermax and hostmax configurable
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2829 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r--Changes.conf2
-rw-r--r--data/example.conf14
-rw-r--r--include/config.h6
-rw-r--r--include/configreader.h4
-rw-r--r--src/config.c2
-rw-r--r--src/core/bs_bot.c24
-rw-r--r--src/core/hs_set.c12
-rw-r--r--src/core/hs_setall.c14
-rw-r--r--src/core/os_chankill.c9
-rw-r--r--src/misc.c2
-rw-r--r--src/modules/hs_request.c20
11 files changed, 69 insertions, 40 deletions
diff --git a/Changes.conf b/Changes.conf
index a0247129a..ccf9c7576 100644
--- a/Changes.conf
+++ b/Changes.conf
@@ -5,6 +5,8 @@ options:enablelogchannel added to auto turn on the logchannel on startup
options:mlock added to configure the default mlock modes on new channels
options:database added for the database modules
options:botmodes added to configure modes BotServ bots should use
+options:userlen added to configure maxiumum ident length
+options:hostlen added to configure maximum hostname length
** MODIFIED CONFIGURATION DIRECTIVES **
options:encryption added enc_sha256
diff --git a/data/example.conf b/data/example.conf
index b346f91e5..4ddaa3ec7 100644
--- a/data/example.conf
+++ b/data/example.conf
@@ -228,6 +228,20 @@ networkinfo
* but recommended.
*/
nicklen = 31
+
+ /* Set this to the maximum allowed ident length on your network.
+ * Be sure to set this correctly, as setting this wrong can result in
+ * Services being disconnected from the network. This directive is optional,
+ * but recommended.
+ */
+ userlen = 10
+
+ /* Set this to the maximum allowed hostname length on your network.
+ * Be sure to set this correctly, as setting this wrong can result in
+ * Services being disconnected from the network. This directive is optional,
+ * but recommended.
+ */
+ hostlen = 64
}
/*
diff --git a/include/config.h b/include/config.h
index 42bacccf0..601013e86 100644
--- a/include/config.h
+++ b/include/config.h
@@ -53,12 +53,6 @@
/* Maximum length of a password */
#define PASSMAX 32
-/* Maximum length of a username */
-#define USERMAX 10
-
-/* Maximum length of a domain */
-#define HOSTMAX 64
-
/**************************************************************************/
#endif /* CONFIG_H */
diff --git a/include/configreader.h b/include/configreader.h
index a22736463..9b66ba7b3 100644
--- a/include/configreader.h
+++ b/include/configreader.h
@@ -406,6 +406,10 @@ class ServerConfig
char *NetworkName;
/* The max legnth of nicks */
unsigned NickLen;
+ /* Max length of idents */
+ unsigned UserLen;
+ /* Max lenghts of hostnames */
+ unsigned HostLen;
/* NickServ Name */
char *s_NickServ;
diff --git a/src/config.c b/src/config.c
index 08d29f692..662d6819b 100644
--- a/src/config.c
+++ b/src/config.c
@@ -608,6 +608,8 @@ int ServerConfig::Read(bool bail)
{"networkinfo", "logbot", "no", new ValueContainerBool(&Config.LogBot), DT_BOOLEAN, NoValidation},
{"networkinfo", "networkname", "", new ValueContainerChar(&Config.NetworkName), DT_CHARPTR, ValidateNotEmpty},
{"networkinfo", "nicklen", "0", new ValueContainerUInt(&Config.NickLen), DT_UINTEGER | DT_NORELOAD, ValidateNickLen},
+ {"networkinfo", "userlen", "10", new ValueContainerUInt(&Config.UserLen), DT_UINTEGER | DT_NORELOAD, NoValidation},
+ {"networkinfo", "hostlen", "64", new ValueContainerUInt(&Config.HostLen), DT_UINTEGER | DT_NORELOAD, NoValidation},
{"options", "encryption", "", new ValueContainerString(&EncModules), DT_STRING | DT_NORELOAD, ValidateNotEmpty},
{"options", "database", "", new ValueContainerString(&DBModules), DT_STRING | DT_NORELOAD, ValidateNotEmpty},
{"options", "userkey1", "0", new ValueContainerLUInt(&Config.UserKey1), DT_LUINTEGER, NoValidation},
diff --git a/src/core/bs_bot.c b/src/core/bs_bot.c
index cfaafac23..9c7ce4854 100644
--- a/src/core/bs_bot.c
+++ b/src/core/bs_bot.c
@@ -39,15 +39,15 @@ class CommandBSBot : public Command
return MOD_CONT;
}
- if (strlen(user) >= USERMAX)
+ if (strlen(user) > Config.UserLen)
{
- notice_lang(Config.s_BotServ, u, BOT_LONG_IDENT, USERMAX - 1);
+ notice_lang(Config.s_BotServ, u, BOT_LONG_IDENT, Config.UserLen);
return MOD_CONT;
}
- if (strlen(user) > HOSTMAX)
+ if (strlen(user) > Config.HostLen)
{
- notice_lang(Config.s_BotServ, u, BOT_LONG_HOST, HOSTMAX);
+ notice_lang(Config.s_BotServ, u, BOT_LONG_HOST, Config.HostLen);
return MOD_CONT;
}
@@ -81,11 +81,11 @@ class CommandBSBot : public Command
return MOD_CONT;
}
- for (ch = user; *ch && (ch - user) < USERMAX; ch++)
+ for (ch = user; *ch && (ch - user) < Config.UserLen; ch++)
{
if (!isalnum(*ch))
{
- notice_lang(Config.s_BotServ, u, BOT_BAD_IDENT, USERMAX - 1);
+ notice_lang(Config.s_BotServ, u, BOT_BAD_IDENT, Config.UserLen);
return MOD_CONT;
}
}
@@ -150,15 +150,15 @@ class CommandBSBot : public Command
return MOD_CONT;
}
- if (user && strlen(user) >= USERMAX)
+ if (user && strlen(user) > Config.UserLen)
{
- notice_lang(Config.s_BotServ, u, BOT_LONG_IDENT, USERMAX - 1);
+ notice_lang(Config.s_BotServ, u, BOT_LONG_IDENT, Config.UserLen);
return MOD_CONT;
}
- if (host && strlen(host) > HOSTMAX)
+ if (host && strlen(host) > Config.HostLen)
{
- notice_lang(Config.s_BotServ, u, BOT_LONG_HOST, HOSTMAX);
+ notice_lang(Config.s_BotServ, u, BOT_LONG_HOST, Config.HostLen);
return MOD_CONT;
}
@@ -210,11 +210,11 @@ class CommandBSBot : public Command
if (user)
{
- for (ch = user; *ch && (ch - user) < USERMAX; ch++)
+ for (ch = user; *ch && (ch - user) < Config.UserLen; ch++)
{
if (!isalnum(*ch))
{
- notice_lang(Config.s_BotServ, u, BOT_BAD_IDENT, USERMAX - 1);
+ notice_lang(Config.s_BotServ, u, BOT_BAD_IDENT, Config.UserLen);
return MOD_CONT;
}
}
diff --git a/src/core/hs_set.c b/src/core/hs_set.c
index e50723d0e..c4b9559e0 100644
--- a/src/core/hs_set.c
+++ b/src/core/hs_set.c
@@ -26,7 +26,7 @@ class CommandHSSet : public Command
{
const char *nick = params[0].c_str();
const char *rawhostmask = params[1].c_str();
- char *hostmask = new char[HOSTMAX];
+ char *hostmask = new char[Config.HostLen];
NickAlias *na;
int32 tmp_time;
@@ -45,9 +45,9 @@ class CommandHSSet : public Command
delete [] hostmask;
return MOD_CONT;
}
- if (strlen(vIdent) > USERMAX - 1)
+ if (strlen(vIdent) > Config.UserLen)
{
- notice_lang(Config.s_HostServ, u, HOST_SET_IDENTTOOLONG, USERMAX);
+ notice_lang(Config.s_HostServ, u, HOST_SET_IDENTTOOLONG, Config.UserLen);
delete [] vIdent;
delete [] rawhostmask;
delete [] hostmask;
@@ -76,11 +76,11 @@ class CommandHSSet : public Command
return MOD_CONT;
}
}
- if (strlen(rawhostmask) < HOSTMAX - 1)
- snprintf(hostmask, HOSTMAX - 1, "%s", rawhostmask);
+ if (strlen(rawhostmask) < Config.HostLen)
+ snprintf(hostmask, Config.HostLen, "%s", rawhostmask);
else
{
- notice_lang(Config.s_HostServ, u, HOST_SET_TOOLONG, HOSTMAX);
+ notice_lang(Config.s_HostServ, u, HOST_SET_TOOLONG, Config.HostLen);
if (vIdent)
{
delete [] vIdent;
diff --git a/src/core/hs_setall.c b/src/core/hs_setall.c
index bb6f9cd15..b15fc29ba 100644
--- a/src/core/hs_setall.c
+++ b/src/core/hs_setall.c
@@ -26,7 +26,7 @@ class CommandHSSetAll : public Command
{
const char *nick = params[0].c_str();
const char *rawhostmask = params[1].c_str();
- char *hostmask = new char[HOSTMAX];
+ char *hostmask = new char[Config.HostLen];
NickAlias *na;
int32 tmp_time;
@@ -36,11 +36,13 @@ class CommandHSSetAll : public Command
if (!(na = findnick(nick)))
{
+ delete [] hostmask;
notice_lang(Config.s_HostServ, u, HOST_NOREG, nick);
return MOD_CONT;
}
else if (na->HasFlag(NS_FORBIDDEN))
{
+ delete [] hostmask;
notice_lang(Config.s_HostServ, u, NICK_X_FORBIDDEN, nick);
return MOD_CONT;
}
@@ -56,9 +58,9 @@ class CommandHSSetAll : public Command
delete [] hostmask;
return MOD_CONT;
}
- if (strlen(vIdent) > USERMAX - 1)
+ if (strlen(vIdent) > Config.UserLen)
{
- notice_lang(Config.s_HostServ, u, HOST_SET_IDENTTOOLONG, USERMAX);
+ notice_lang(Config.s_HostServ, u, HOST_SET_IDENTTOOLONG, Config.UserLen);
delete [] vIdent;
delete [] rawhostmask;
delete [] hostmask;
@@ -88,11 +90,11 @@ class CommandHSSetAll : public Command
}
}
- if (strlen(rawhostmask) < HOSTMAX - 1)
- snprintf(hostmask, HOSTMAX - 1, "%s", rawhostmask);
+ if (strlen(rawhostmask) < Config.HostLen)
+ snprintf(hostmask, Config.HostLen, "%s", rawhostmask);
else
{
- notice_lang(Config.s_HostServ, u, HOST_SET_TOOLONG, HOSTMAX);
+ notice_lang(Config.s_HostServ, u, HOST_SET_TOOLONG, Config.HostLen);
if (vIdent)
{
delete [] vIdent;
diff --git a/src/core/os_chankill.c b/src/core/os_chankill.c
index bdb3ecc69..2920e0b4d 100644
--- a/src/core/os_chankill.c
+++ b/src/core/os_chankill.c
@@ -27,7 +27,7 @@ class CommandOSChanKill : public Command
const char *expiry, *channel;
char reason[BUFSIZE];
time_t expires;
- char mask[USERMAX + HOSTMAX + 2];
+ char *mask = new char[Config.UserLen + Config.HostLen + 2];
unsigned last_param = 1;
Channel *c;
@@ -47,6 +47,7 @@ class CommandOSChanKill : public Command
if (expires != 0 && expires < 60)
{
notice_lang(Config.s_OperServ, u, BAD_EXPIRY_TIME);
+ delete [] mask;
return MOD_CONT;
}
else if (expires > 0)
@@ -55,6 +56,7 @@ class CommandOSChanKill : public Command
if (params.size() <= last_param)
{
this->OnSyntaxError(u, "");
+ delete [] mask;
return MOD_CONT;
}
snprintf(reason, sizeof(reason), "%s%s", params[last_param].c_str(), (params.size() > last_param + 1 ? params[last_param + 1].c_str() : ""));
@@ -76,8 +78,8 @@ class CommandOSChanKill : public Command
if (is_oper(uc->user))
continue;
- strlcpy(mask, "*@", sizeof(mask)); /* Use *@" for the akill's, */
- strlcat(mask, uc->user->host, sizeof(mask));
+ strlcpy(mask, "*@", Config.UserLen + Config.HostLen + 2); /* Use *@" for the akill's, */
+ strlcat(mask, uc->user->host, Config.UserLen + Config.HostLen + 2);
add_akill(NULL, mask, Config.s_OperServ, expires, realreason.c_str());
check_akill(uc->user->nick.c_str(), uc->user->GetIdent().c_str(), uc->user->host, NULL, NULL);
}
@@ -87,6 +89,7 @@ class CommandOSChanKill : public Command
else
notice_lang(Config.s_OperServ, u, CHAN_X_NOT_IN_USE, channel);
}
+ delete [] mask;
return MOD_CONT;
}
diff --git a/src/misc.c b/src/misc.c
index a39886ccb..953d28fcd 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -482,7 +482,7 @@ int doValidHost(const char *host, int type)
len = strlen(host);
- if (len > HOSTMAX) {
+ if (len > Config.HostLen) {
return 0;
}
diff --git a/src/modules/hs_request.c b/src/modules/hs_request.c
index 018fc20be..fdacc91a2 100644
--- a/src/modules/hs_request.c
+++ b/src/modules/hs_request.c
@@ -80,7 +80,7 @@ class CommandHSRequest : public Command
{
const char *nick;
const char *rawhostmask = params[0].c_str();
- char hostmask[HOSTMAX];
+ char *hostmask = new char[Config.HostLen];
NickAlias *na;
char *s;
char *vIdent = NULL;
@@ -96,13 +96,15 @@ class CommandHSRequest : public Command
{
me->NoticeLang(Config.s_HostServ, u, LNG_REQUEST_SYNTAX);
delete [] vIdent;
+ delete [] hostmask;
return MOD_CONT;
}
- if (strlen(vIdent) > USERMAX - 1)
+ if (strlen(vIdent) > Config.UserLen)
{
- notice_lang(Config.s_HostServ, u, HOST_SET_IDENTTOOLONG, USERMAX);
+ notice_lang(Config.s_HostServ, u, HOST_SET_IDENTTOOLONG, Config.UserLen);
delete [] vIdent;
delete [] rawhostmask;
+ delete [] hostmask;
return MOD_CONT;
}
else
@@ -114,6 +116,7 @@ class CommandHSRequest : public Command
notice_lang(Config.s_HostServ, u, HOST_SET_IDENT_ERROR);
delete [] vIdent;
delete [] rawhostmask;
+ delete [] hostmask;
return MOD_CONT;
}
}
@@ -123,19 +126,21 @@ class CommandHSRequest : public Command
notice_lang(Config.s_HostServ, u, HOST_NO_VIDENT);
delete [] vIdent;
delete [] rawhostmask;
+ delete [] hostmask;
return MOD_CONT;
}
}
- if (strlen(rawhostmask) < HOSTMAX)
- snprintf(hostmask, HOSTMAX, "%s", rawhostmask);
+ if (strlen(rawhostmask) < Config.HostLen)
+ snprintf(hostmask, Config.HostLen, "%s", rawhostmask);
else
{
- notice_lang(Config.s_HostServ, u, HOST_SET_TOOLONG, HOSTMAX);
+ notice_lang(Config.s_HostServ, u, HOST_SET_TOOLONG, Config.HostLen);
if (vIdent)
{
delete [] vIdent;
delete [] rawhostmask;
}
+ delete [] hostmask;
return MOD_CONT;
}
@@ -147,6 +152,7 @@ class CommandHSRequest : public Command
delete [] vIdent;
delete [] rawhostmask;
}
+ delete [] hostmask;
return MOD_CONT;
}
@@ -163,6 +169,7 @@ class CommandHSRequest : public Command
delete [] vIdent;
delete [] rawhostmask;
}
+ delete [] hostmask;
return MOD_CONT;
}
}
@@ -180,6 +187,7 @@ class CommandHSRequest : public Command
delete [] vIdent;
delete [] rawhostmask;
}
+ delete [] hostmask;
return MOD_CONT;
}