From 0e7f232b3d5ecb484d9d91bdd7e4b6d4e7791585 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Sat, 9 Aug 2025 13:25:03 +0100 Subject: Correctly process 353 RPL_NAMREPLYs for secret and private channels. --- TODO | 2 -- functions.c | 8 +++++--- message.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/TODO b/TODO index df0cdb9..895e3c2 100644 --- a/TODO +++ b/TODO @@ -56,8 +56,6 @@ Ability to check for updates (and optional at startup?). Absurd CPU usage and duration doing "/BLABOUNCER REPLAY 24:0" approx. 14/09/2024 17:35. -User has quit not always listed in all channel log files? (e.g. lebhome 12/11/2024 22:49:37) - Custom OpenSSL protocols/ciphers? NickServ HELP with SA receiving full message in one go? e.g. oper 05/01/2025 10:06:22. Blabouncer or Anope or UnrealIRCD or something else? diff --git a/functions.c b/functions.c index 8ef2b21..54e2663 100644 --- a/functions.c +++ b/functions.c @@ -1596,7 +1596,7 @@ int isnickinanychannel(struct channel *channels, int maxchannelcount, char *nick return 0; } -// Populate our channels struct with all nicks in a RPL_NAMREPLY +// Populate our channels struct with all nicks in a 353 RPL_NAMREPLY // Returns 1 on success or 0 on failure int addnamereplytochannel(char *namereply, struct channel *channels, int maxchannelcount) { //:irc.tghost.co.uk 353 blabounce = #blabouncer :blabounce bbnick ~@l_bratch @l_blabnc Hughbla Bratchbot ars @@ -1609,10 +1609,12 @@ int addnamereplytochannel(char *namereply, struct channel *channels, int maxchan // Strip the leading ':' stripprefix(strcopy, 1); - // Find the start of the channel name, which comes after the first '=' followed by a space + // Find the start of the channel name, which comes after the first '=', '*', or '@', followed by a space + // From RFC 2812: + // "@" is used for secret channels, "*" for private channels, and "=" for others (public channels). int channelpos = -1; for (size_t i = 0; i < strlen(strcopy) - 2; i++) { - if (strcopy[i] == '=' && strcopy[i + 1] == ' ' && strcopy[i + 2] != '\0') { + if ((strcopy[i] == '=' || strcopy[i] == '*' || strcopy[i] == '@') && strcopy[i + 1] == ' ' && strcopy[i + 2] != '\0') { // Name found channelpos = i + 2; break; diff --git a/message.c b/message.c index 99ac0ca..f8e14cb 100644 --- a/message.c +++ b/message.c @@ -384,7 +384,7 @@ int processservermessage(SSL *server_ssl, char *str, struct client *clients, int // Update our local channels struct with all nicks from this RPL_NAMREPLY if (!addnamereplytochannel(str, channels, ircdstate->maxchannelcount)) { - debugprint(DEBUG_CRIT, "Failed to add RPL_NAMREPLY to channels.\n"); + debugprint(DEBUG_CRIT, "processservermessage(): Failed to add RPL_NAMREPLY to channels.\n"); } return 1; -- cgit v1.2.3