From 6e334f7cf0e166359848e03673f25c5b6bb83d37 Mon Sep 17 00:00:00 2001 From: Stuart Walsh Date: Wed, 13 Jul 2016 10:37:51 +0100 Subject: [PATCH] Move the check for max number of channels limit into can_join so that is applies everywhere instead of just one place --- modules/core/m_join.c | 14 ++++---------- src/channel.c | 6 ++++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/core/m_join.c b/modules/core/m_join.c index 57bd259f5..6c950bc46 100644 --- a/modules/core/m_join.c +++ b/modules/core/m_join.c @@ -179,15 +179,6 @@ m_join(struct Client *client_p, struct Client *source_p, continue; } - if ((dlink_list_length(&source_p->channel) >= ConfigChannel.max_chans_per_user) && - (!IsOper(source_p) || (dlink_list_length(&source_p->channel) >= - ConfigChannel.max_chans_per_user * 3))) - { - sendto_one(source_p, form_str(ERR_TOOMANYCHANNELS), - me.name, source_p->name, chan); - break; - } - if ((chptr = hash_find_channel(chan)) != NULL) { if (IsMember(source_p, chptr)) @@ -238,7 +229,10 @@ m_join(struct Client *client_p, struct Client *source_p, { sendto_one(source_p, form_str(i), me.name, source_p->name, chptr->chname); - continue; + if(i == ERR_TOOMANYCHANNELS) + break; + else + continue; } if(i != 0 && IsGod(source_p) && MyClient(source_p)) diff --git a/src/channel.c b/src/channel.c index edf9412ad..592c5500f 100644 --- a/src/channel.c +++ b/src/channel.c @@ -689,6 +689,12 @@ can_join(struct Client *source_p, struct Channel *chptr, const char *key) if(IsService(source_p)) return 0; + if ((dlink_list_length(&source_p->channel) >= ConfigChannel.max_chans_per_user) && + (!IsOper(source_p) || (dlink_list_length(&source_p->channel) >= + ConfigChannel.max_chans_per_user * 3))) + return ERR_TOOMANYCHANNELS; + + if (is_banned(chptr, source_p)) return ERR_BANNEDFROMCHAN;