Module: ngircd.git
Branch: master
Commit: f8405b1a4f032a125372b03711f6bed1ecac2bd6
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=f8405b1a…
Author: Alexander Barton <alex(a)barton.de>
Date: Fri Jan 6 20:05:07 2012 +0100
New function IRC_CheckListTooBig() to check size of list replies
It the limit is reached, a NOTICE is sent to the client and list
processing should stop.
---
src/ngircd/irc.c | 31 ++++++++++++++++++++++++++++++-
src/ngircd/irc.h | 5 ++++-
2 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/src/ngircd/irc.c b/src/ngircd/irc.c
index 7a87137..10e3e45 100644
--- a/src/ngircd/irc.c
+++ b/src/ngircd/irc.c
@@ -1,6 +1,6 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2004 Alexander Barton <alex(a)barton.de>
+ * Copyright (c)2001-2012 Alexander Barton (alex(a)barton.de) and Contributors.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -45,6 +45,35 @@ static bool Send_Message_Mask PARAMS((CLIENT *from, char *command,
bool SendErrors));
+/**
+ * Check if a list limit is reached and inform client accordingly.
+ *
+ * @param From The client.
+ * @param Count Reply item count.
+ * @param Limit Reply limit.
+ * @param Name Name of the list.
+ * @return true if list limit has been reached; false otherwise.
+ */
+GLOBAL bool
+IRC_CheckListTooBig(CLIENT *From, const int Count, const int Limit,
+ const char *Name)
+{
+ assert(From != NULL);
+ assert(Count >= 0);
+ assert(Limit > 0);
+ assert(Name != NULL);
+
+ if (Count < Limit)
+ return false;
+
+ (void)IRC_WriteStrClient(From,
+ "NOTICE %s :%s list limit (%d) reached!",
+ Client_ID(From), Name, Limit);
+ IRC_SetPenalty(From, 2);
+ return true;
+}
+
+
GLOBAL bool
IRC_ERROR( CLIENT *Client, REQUEST *Req )
{
diff --git a/src/ngircd/irc.h b/src/ngircd/irc.h
index cdeb745..c2f9b66 100644
--- a/src/ngircd/irc.h
+++ b/src/ngircd/irc.h
@@ -1,6 +1,6 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2008 Alexander Barton (alex(a)barton.de)
+ * Copyright (c)2001-2012 Alexander Barton (alex(a)barton.de) and Contributors.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,6 +17,9 @@
* IRC commands (header)
*/
+GLOBAL bool IRC_CheckListTooBig PARAMS((CLIENT *From, const int Count,
+ const int Limit, const char *Name));
+
GLOBAL bool IRC_ERROR PARAMS((CLIENT *Client, REQUEST *Req));
GLOBAL bool IRC_KILL PARAMS((CLIENT *Client, REQUEST *Req));
GLOBAL bool IRC_NOTICE PARAMS((CLIENT *Client, REQUEST *Req));
Module: ngircd.git
Branch: master
Commit: 470d2e236258ce72c6d574b04f1400c0fedc4a3a
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=470d2e23…
Author: Alexander Barton <alex(a)barton.de>
Date: Fri Jan 6 17:46:52 2012 +0100
RPL_ISUPPORT (numeric 005): Report MODES=<MAX_CMODES_ARG>
"Maximum number of channel modes with parameter allowed per MODE command."
See <http://www.irc.org/tech_docs/005.html> for details.
---
src/ngircd/irc-info.c | 4 ++--
src/ngircd/messages.h | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/ngircd/irc-info.c b/src/ngircd/irc-info.c
index 42b2264..c241265 100644
--- a/src/ngircd/irc-info.c
+++ b/src/ngircd/irc-info.c
@@ -1,6 +1,6 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2011 Alexander Barton (alex(a)barton.de) and Contributors.
+ * Copyright (c)2001-2012 Alexander Barton (alex(a)barton.de) and Contributors.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1568,7 +1568,7 @@ IRC_Send_ISUPPORT(CLIENT * Client)
return IRC_WriteStrClient(Client, RPL_ISUPPORT2_MSG, Client_ID(Client),
CHANNEL_NAME_LEN - 1, Conf_MaxNickLength - 1,
COMMAND_LEN - 23, CLIENT_AWAY_LEN - 1,
- COMMAND_LEN - 113);
+ COMMAND_LEN - 113, MAX_CMODES_ARG);
} /* IRC_Send_ISUPPORT */
diff --git a/src/ngircd/messages.h b/src/ngircd/messages.h
index 7bf7367..cf11ca5 100644
--- a/src/ngircd/messages.h
+++ b/src/ngircd/messages.h
@@ -1,6 +1,6 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2010 Alexander Barton <alex(a)barton.de>
+ * Copyright (c)2001-2012 Alexander Barton (alex(a)barton.de) and Contributors.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
#define RPL_CREATED_MSG "003 %s :This server has been started %s"
#define RPL_MYINFO_MSG "004 %s %s ngircd-%s %s %s"
#define RPL_ISUPPORT1_MSG "005 %s RFC2812 IRCD=ngIRCd CASEMAPPING=ascii PREFIX=(ov)@+ CHANTYPES=#&+ CHANMODES=bI,k,l,imnPst CHANLIMIT=#&+:%d :are supported on this server"
-#define RPL_ISUPPORT2_MSG "005 %s CHANNELLEN=%d NICKLEN=%d TOPICLEN=%d AWAYLEN=%d KICKLEN=%d PENALTY :are supported on this server"
+#define RPL_ISUPPORT2_MSG "005 %s CHANNELLEN=%d NICKLEN=%d TOPICLEN=%d AWAYLEN=%d KICKLEN=%d MODES=%d PENALTY :are supported on this server"
#define RPL_TRACELINK_MSG "200 %s Link %s-%s %s %s V%s %ld %d %d"
#define RPL_TRACEOPERATOR_MSG "204 %s Oper 2 :%s"
Module: ngircd.git
Branch: master
Commit: 98493077a2d044aa08ee5cb4bd7054579e30fb57
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=98493077…
Author: Alexander Barton <alex(a)barton.de>
Date: Fri Jan 6 17:27:29 2012 +0100
channel modes: only handle MAX_CMODES_ARG modes with arguments
Limit the MODE command to handle a maximum of MAX_CMODES_ARG (5) channel
modes that require an argument (+Ibkl) per call.
Please note: Further modes that require arguments are silently ignored
and end the handling of any further modes.
This is similar to the behavior of ircd2.11 (silently ignores but seems
to handle other modes) as well as ircd-seven (silently ignores but handles
some(!) other modes) ...
---
src/ngircd/defines.h | 5 ++++-
src/ngircd/irc-mode.c | 8 +++++++-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/ngircd/defines.h b/src/ngircd/defines.h
index 4bcb6af..b894dbc 100644
--- a/src/ngircd/defines.h
+++ b/src/ngircd/defines.h
@@ -1,6 +1,6 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2010 Alexander Barton (alex(a)barton.de)
+ * Copyright (c)2001-2012 Alexander Barton (alex(a)barton.de)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -32,6 +32,9 @@
#define MAX_WHOWAS 64 /* Max. number of WHOWAS items */
#define DEFAULT_WHOWAS 5 /* default count for WHOWAS command */
+#define MAX_CMODES_ARG 5 /* Max. number of channel modes with
+ * arguments per MODE command */
+
#define CONNECTION_POOL 100 /* Size of default connection pool */
#define CLIENT_ID_LEN 64 /* Max. length of an IRC ID; see RFC
diff --git a/src/ngircd/irc-mode.c b/src/ngircd/irc-mode.c
index 01f8762..9afe907 100644
--- a/src/ngircd/irc-mode.c
+++ b/src/ngircd/irc-mode.c
@@ -375,7 +375,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
char the_modes[COMMAND_LEN], the_args[COMMAND_LEN], x[2],
argadd[CLIENT_PASS_LEN], *mode_ptr;
bool connected, set, skiponce, retval, onchannel, modeok, use_servermode;
- int mode_arg, arg_arg;
+ int mode_arg, arg_arg, mode_arg_count = 0;
CLIENT *client;
long l;
size_t len;
@@ -491,6 +491,8 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
Client_ID(Origin), Channel_Name(Channel));
break;
case 'k': /* Channel key */
+ if (mode_arg_count++ >= MAX_CMODES_ARG)
+ break;
if (!set) {
if (modeok)
x[0] = *mode_ptr;
@@ -525,6 +527,8 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
}
break;
case 'l': /* Member limit */
+ if (mode_arg_count++ >= MAX_CMODES_ARG)
+ break;
if (!set) {
if (modeok)
x[0] = *mode_ptr;
@@ -635,6 +639,8 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
/* --- Channel lists --- */
case 'I': /* Invite lists */
case 'b': /* Ban lists */
+ if (mode_arg_count++ >= MAX_CMODES_ARG)
+ break;
if (arg_arg > mode_arg) {
/* modify list */
if (modeok) {
Module: ngircd.git
Branch: master
Commit: 05cc9bf9b064c7048f6b197462a686c5a9100798
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=05cc9bf9…
Author: Alexander Barton <alex(a)barton.de>
Date: Fri Jan 6 03:26:24 2012 +0100
Conn_Write(): Make sure there is a client when detecting its type
The assert(client != NULL) got triggered during our tests, so there is
an error path that resulted in the connection being still established
(sock >= 0) but the client structure already freed.
So Conn_Write() should handle it!
---
src/ngircd/conn.c | 21 ++++++++++++---------
1 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c
index d9d73e8..5f3c18a 100644
--- a/src/ngircd/conn.c
+++ b/src/ngircd/conn.c
@@ -936,22 +936,25 @@ Conn_Write( CONN_ID Idx, char *Data, size_t Len )
assert( Data != NULL );
assert( Len > 0 );
- c = Conn_GetClient(Idx);
- assert( c != NULL);
-
- /* Servers do get special write buffer limits, so they can generate
- * all the messages that are required while peering. */
- if (Client_Type(c) == CLIENT_SERVER)
- writebuf_limit = WRITEBUFFER_SLINK_LEN;
-
/* Is the socket still open? A previous call to Conn_Write()
* may have closed the connection due to a fatal error.
* In this case it is sufficient to return an error, as well. */
- if( My_Connections[Idx].sock <= NONE ) {
+ if (My_Connections[Idx].sock <= NONE) {
LogDebug("Skipped write on closed socket (connection %d).", Idx);
return false;
}
+ /* Make sure that there still exists a CLIENT structure associated
+ * with this connection and check if this is a server or not: */
+ c = Conn_GetClient(Idx);
+ if (c) {
+ /* Servers do get special write buffer limits, so they can
+ * generate all the messages that are required while peering. */
+ if (Client_Type(c) == CLIENT_SERVER)
+ writebuf_limit = WRITEBUFFER_SLINK_LEN;
+ } else
+ LogDebug("Write on socket without client (connection %d)!?", Idx);
+
#ifdef ZLIB
if ( Conn_OPTION_ISSET( &My_Connections[Idx], CONN_ZIP )) {
/* Compressed link: