From 4544c4b56eae07e9da7ed0b4b0329b2989494f0b Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Sun, 9 Apr 2023 03:17:18 +0200 Subject: Fix ban list request handling - support both "MODE #channel b" and "MODE #channel +b". --- message.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'message.c') diff --git a/message.c b/message.c index 5458b72..7067776 100644 --- a/message.c +++ b/message.c @@ -602,6 +602,7 @@ int processservermessage(SSL *server_ssl, char *str, struct client *clients, int sendtoclient(clients[i].fd, str, clients, settings, 0); // And clear the pending flag if it's 368 (RPL_ENDOFBANLIST) if (strncmp(tokens[1], "368", strlen(tokens[1])) == 0) { + debugprint(DEBUG_FULL, "368 (RPL_ENDOFBANLIST) received, setting pendingban = 0 on client fd %d.\n", clients[i].fd); clients[i].pendingban = 0; } } @@ -1206,8 +1207,9 @@ int processclientmessage(SSL *server_ssl, char *str, struct client *clients, int if (strncasecmp(tokens[0], "MODE", strlen(tokens[0])) == 0) { debugprint(DEBUG_FULL, "Client MODE found and it is: %s with length %zd! Analysing...\n", tokens[0], strlen(tokens[0])); // Is it a ban MODE request (MODE #channel b)? - // TODO - Can something else beginning with "b" be in this position? Need a length comparison? - if (counter >= 3 && strncmp(tokens[2], "b", strlen("b")) == 0) { + if (counter >= 3 && (((strlen(tokens[2]) == strlen("b")) && strncmp(tokens[2], "b", strlen("b")) == 0) + || ((strlen(tokens[2]) == strlen("+b")) && strncmp(tokens[2], "+b", strlen("+b")) == 0)) + ) { debugprint(DEBUG_FULL, "Ban MODE request received, marking as pending.\n"); clients[clientindex].pendingban = 1; } else if (counter == 2) { -- cgit v1.2.3