Skip to content

Instantly share code, notes, and snippets.

@aji
Created April 24, 2012 00:23
Show Gist options
  • Select an option

  • Save aji/2474882 to your computer and use it in GitHub Desktop.

Select an option

Save aji/2474882 to your computer and use it in GitHub Desktop.
diff --git a/dist/atheme.conf.example b/dist/atheme.conf.example
index 30b7db9..7bcf611 100644
--- a/dist/atheme.conf.example
+++ b/dist/atheme.conf.example
@@ -1508,6 +1508,13 @@ botserv {
* to be assigned to that channel.
*/
min_users = 0;
+
+ /* (*)nicklen
+ * Maximum nickname length. This should match the maximum nickname
+ * length of your IRCd so that Atheme does not get unlinked for
+ * try to introduce a bad nickname.
+ */
+ nicklen = 50;
};
/* GroupServ configuration.
diff --git a/modules/botserv/main.c b/modules/botserv/main.c
index 6e757d7..0ca6c2c 100644
--- a/modules/botserv/main.c
+++ b/modules/botserv/main.c
@@ -39,6 +39,7 @@ fn_botserv_bot_find botserv_bot_find;
service_t *botsvs;
unsigned int min_users = 0;
+unsigned int bs_nicklen = 0;
E mowgli_list_t mychan;
@@ -584,7 +585,8 @@ static void bs_cmd_change(sourceinfo_t *si, int parc, char *parv[])
}
if (parc >= 2 && (!valid_misc_field(parv[1], NICKLEN - 1) ||
- strchr(parv[1], '.') || isdigit(*parv[1])))
+ strchr(parv[1], '.') || isdigit(*parv[1])
+ || strlen(parv[1]) > bs_nicklen))
{
command_fail(si, fault_badparams, _("\2%s\2 is an invalid nickname."), parv[1]);
return;
@@ -681,7 +683,7 @@ static void bs_cmd_add(sourceinfo_t *si, int parc, char *parv[])
snprintf(buf, sizeof(buf), "%s", parv[3]);
if (!valid_misc_field(parv[0], NICKLEN - 1) || strchr(parv[0], '.') ||
- isdigit(*parv[0]))
+ isdigit(*parv[0]) || strlen(parv[0]) > bs_nicklen)
{
command_fail(si, fault_badparams, _("\2%s\2 is an invalid nickname."), parv[0]);
return;
@@ -956,6 +958,7 @@ void _modinit(module_t *m)
botsvs = service_add("botserv", NULL);
add_uint_conf_item("MIN_USERS", &botsvs->conf_table, 0, &min_users, 0, 65535, 0);
+ add_uint_conf_item("NICKLEN", &botsvs->conf_table, 0, &bs_nicklen, 0, NICKLEN, 50);
service_bind_command(botsvs, &bs_bot);
service_bind_command(botsvs, &bs_assign);
service_bind_command(botsvs, &bs_unassign);
@@ -1002,6 +1005,7 @@ void _moddeinit(module_unload_intent_t intent)
service_unbind_command(botsvs, &bs_unassign);
service_unbind_command(botsvs, &bs_botlist);
del_conf_item("MIN_USERS", &botsvs->conf_table);
+ del_conf_item("NICKLEN", &botsvs->conf_table);
hook_del_channel_join(bs_join);
hook_del_channel_part(bs_part);
hook_del_channel_drop(bs_channel_drop);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment