about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorBrett Smith <brett@w3.org>2012-10-25 14:46:29 -0400
committerBrett Smith <brett@w3.org>2012-10-25 14:46:29 -0400
commit32f63abb59b5c9f47b4d517e0bbf9cc73fd044dc (patch)
treee52ce2cd76707402c8f0ae1577ff202211aa1604 /src
parent23572af942399288bcf4e67245563b05ff4fc0f7 (diff)
downloadngircd-32f63abb59b5c9f47b4d517e0bbf9cc73fd044dc.tar.gz
ngircd-32f63abb59b5c9f47b4d517e0bbf9cc73fd044dc.zip
Make the maximum /list reply length a configurable limit.
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/conf.c8
-rw-r--r--src/ngircd/conf.h3
-rw-r--r--src/ngircd/defines.h3
-rw-r--r--src/ngircd/irc-channel.c7
4 files changed, 15 insertions, 6 deletions
diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c
index 4ac37ad4..b6005707 100644
--- a/src/ngircd/conf.c
+++ b/src/ngircd/conf.c
@@ -350,6 +350,7 @@ Conf_Test( void )
 	printf("  MaxConnectionsIP = %d\n", Conf_MaxConnectionsIP);
 	printf("  MaxJoins = %d\n", Conf_MaxJoins > 0 ? Conf_MaxJoins : -1);
 	printf("  MaxNickLength = %u\n", Conf_MaxNickLength - 1);
+	printf("  MaxListSize = %d\n", Conf_MaxListSize);
 	printf("  PingTimeout = %d\n", Conf_PingTimeout);
 	printf("  PongTimeout = %d\n", Conf_PongTimeout);
 	puts("");
@@ -706,6 +707,7 @@ Set_Defaults(bool InitServers)
 	Conf_MaxConnectionsIP = 5;
 	Conf_MaxJoins = 10;
 	Conf_MaxNickLength = CLIENT_NICK_LEN_DEFAULT;
+	Conf_MaxListSize = 100;
 	Conf_PingTimeout = 120;
 	Conf_PongTimeout = 20;
 
@@ -1457,6 +1459,12 @@ Handle_LIMITS(int Line, char *Var, char *Arg)
 		Conf_MaxNickLength = Handle_MaxNickLength(Line, Arg);
 		return;
 	}
+	if (strcasecmp(Var, "MaxListSize") == 0) {
+		Conf_MaxListSize = atoi(Arg);
+		if (!Conf_MaxListSize && strcmp(Arg, "0"))
+			Config_Error_NaN(Line, Var);
+		return;
+	}
 	if (strcasecmp(Var, "PingTimeout") == 0) {
 		Conf_PingTimeout = atoi(Arg);
 		if (Conf_PingTimeout < 5) {
diff --git a/src/ngircd/conf.h b/src/ngircd/conf.h
index 90d74d20..541fdb29 100644
--- a/src/ngircd/conf.h
+++ b/src/ngircd/conf.h
@@ -220,6 +220,9 @@ GLOBAL int Conf_MaxConnectionsIP;
 /** Maximum length of a nick name */
 GLOBAL unsigned int Conf_MaxNickLength;
 
+/** Maximum number of channels returned to /list */
+GLOBAL int Conf_MaxListSize;
+
 #ifndef STRICT_RFC
 
 /** Require "AUTH PING-PONG" on login */
diff --git a/src/ngircd/defines.h b/src/ngircd/defines.h
index b387493c..345f1bed 100644
--- a/src/ngircd/defines.h
+++ b/src/ngircd/defines.h
@@ -181,9 +181,6 @@
 
 /* Defaults and limits for IRC commands */
 
-/** Max. number of LIST replies. */
-#define MAX_RPL_LIST 100
-
 /** Max. number of elemets allowed in channel invite and ban lists. */
 #define MAX_HNDL_CHANNEL_LISTS 50
 
diff --git a/src/ngircd/irc-channel.c b/src/ngircd/irc-channel.c
index f9d2dc12..ed4839af 100644
--- a/src/ngircd/irc-channel.c
+++ b/src/ngircd/irc-channel.c
@@ -679,9 +679,10 @@ IRC_LIST( CLIENT *Client, REQUEST *Req )
 				if (!strchr(Channel_Modes(chan), 's')
 				    || Channel_IsMemberOf(chan, from)
 				    || (!Conf_MorePrivacy && Client_OperByMe(Client))) {
-					if (IRC_CheckListTooBig(from, count,
-								 MAX_RPL_LIST,
-								 "LIST"))
+					if ((Conf_MaxListSize > 0)
+					    && IRC_CheckListTooBig(from, count,
+								   Conf_MaxListSize,
+								   "LIST"))
 						break;
 					if (!IRC_WriteStrClient(from,
 					     RPL_LIST_MSG, Client_ID(from),