From b07f02fb11afceadfa72141c3bf8bcca701c6256 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Sun, 19 May 2024 18:49:33 +0200 Subject: [PATCH] Fix +b ~forward not taking into account +e (ban exemptions). Reported by rafaelgrether in https://bugs.unrealircd.org/view.php?id=6410 --- src/modules/chanmodes/link.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/modules/chanmodes/link.c b/src/modules/chanmodes/link.c index 81f22cbf0..b09b40dbf 100644 --- a/src/modules/chanmodes/link.c +++ b/src/modules/chanmodes/link.c @@ -421,8 +421,30 @@ int link_pre_localjoin_cb(Client *client, Channel *channel, const char *key) b->banstr = banmask; if (ban_check_mask(b)) { - safe_free(b); - return link_doforward(client, channel, banchan, LINKTYPE_BAN); + /* Forward ban matched, now check for +e */ + Ban *ex = NULL; + for (ex = channel->exlist; ex; ex = ex->next) + { + b->banstr = ex->banstr; + if (ban_check_mask(b)) + { + /* except matched, break inner loop */ + break; + } + } + if (ex == NULL) + { + /* A ~forward ban matched, go for it.. */ + safe_free(b); + return link_doforward(client, channel, banchan, LINKTYPE_BAN); + } else { + /* Break the outer loop as well: the user is exempt, + * so it makes no sense to check other bans anymore. + * no "safe_free(b);" here because that is taken + * care of further down. + */ + break; + } } }