Module: ngircd.git
Branch: master
Commit: 3593c1dfabd944197a79dd964f8005b8265a20a8
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=3593c1df…
Author: Alexander Barton <alex(a)barton.de>
Date: Wed Dec 28 15:07:24 2011 +0100
LUSERS reply: only count "visible" channels
Rename Channel_Count() to Channel_CountVisible() and only count channels
that are visible to the requesting client, so the existence of secret
channels is no longer revealed by using LUSERS.
---
src/ngircd/channel.c | 21 ++++++++++++++++-----
src/ngircd/channel.h | 2 +-
src/ngircd/irc-info.c | 3 ++-
3 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/src/ngircd/channel.c b/src/ngircd/channel.c
index 2dbf53a..4d323f2 100644
--- a/src/ngircd/channel.c
+++ b/src/ngircd/channel.c
@@ -352,20 +352,31 @@ Channel_Quit( CLIENT *Client, const char *Reason )
} /* Channel_Quit */
+/**
+ * Get number of channels this server knows and that are "visible" to
+ * the given client. If no client is given, all channels will be counted.
+ *
+ * @param Client The client to check or NULL.
+ * @return Number of channels visible to the client.
+ */
GLOBAL unsigned long
-Channel_Count( void )
+Channel_CountVisible (CLIENT *Client)
{
CHANNEL *c;
unsigned long count = 0;
c = My_Channels;
- while( c )
- {
- count++;
+ while(c) {
+ if (Client) {
+ if (!strchr(Channel_Modes(c), 's')
+ || Channel_IsMemberOf(c, Client))
+ count++;
+ } else
+ count++;
c = c->next;
}
return count;
-} /* Channel_Count */
+}
GLOBAL unsigned long
diff --git a/src/ngircd/channel.h b/src/ngircd/channel.h
index f44e194..ba3f2ca 100644
--- a/src/ngircd/channel.h
+++ b/src/ngircd/channel.h
@@ -72,7 +72,7 @@ GLOBAL void Channel_Quit PARAMS(( CLIENT *Client, const char *Reason ));
GLOBAL void Channel_Kick PARAMS((CLIENT *Peer, CLIENT *Target, CLIENT *Origin,
const char *Name, const char *Reason));
-GLOBAL unsigned long Channel_Count PARAMS(( void ));
+GLOBAL unsigned long Channel_CountVisible PARAMS((CLIENT *Client));
GLOBAL unsigned long Channel_MemberCount PARAMS(( CHANNEL *Chan ));
GLOBAL int Channel_CountForUser PARAMS(( CLIENT *Client ));
diff --git a/src/ngircd/irc-info.c b/src/ngircd/irc-info.c
index cdd03bb..0119257 100644
--- a/src/ngircd/irc-info.c
+++ b/src/ngircd/irc-info.c
@@ -1317,7 +1317,8 @@ IRC_Send_LUSERS(CLIENT *Client)
/* Number of created channels */
if (!IRC_WriteStrClient(Client, RPL_LUSERCHANNELS_MSG,
- Client_ID(Client), Channel_Count()))
+ Client_ID(Client),
+ Channel_CountVisible(Client)))
return DISCONNECTED;
/* Number of local users, services and servers */
Module: ngircd.git
Branch: master
Commit: 8a8e8a3a23576ccdf06aec7d0a2e6a0d8584a9d8
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=8a8e8a3a…
Author: Alexander Barton <alex(a)barton.de>
Date: Sun Dec 25 20:11:43 2011 +0100
IRC_xLINE(): output an error message for unexpected "lines"
This fixes:
irc-oper.c: In function ‘IRC_xLINE’:
irc-oper.c:429: warning: ‘class’ may be used uninitialized in this function
irc-oper.c:430: warning: ‘class_c’ may be used uninitialized in this function
---
src/ngircd/irc-oper.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/src/ngircd/irc-oper.c b/src/ngircd/irc-oper.c
index 1b269e3..21577f0 100644
--- a/src/ngircd/irc-oper.c
+++ b/src/ngircd/irc-oper.c
@@ -450,6 +450,11 @@ IRC_xLINE(CLIENT *Client, REQUEST *Req)
case 'K':
class = CLASS_KLINE; class_c = 'K';
break;
+ default:
+ Log(LOG_CRIT,
+ "IRC_xLINE() called for unknown line: %c!? Ignored.",
+ Req->command[0]);
+ return CONNECTED;
}
if (Req->argc == 1) {