From: Val Lorentz Date: Fri, 19 Apr 2024 21:00:20 +0000 (+0200) Subject: Fix channel symbol returned by RPL_NAMREPLY for secret channels X-Git-Tag: rel-27~6 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=commitdiff_plain;h=d4fb21f3542ee2a42aecdddc73a76a6ff41fcacd Fix channel symbol returned by RPL_NAMREPLY for secret channels References: - https://modern.ircdocs.horse/#rplnamreply-353 - https://datatracker.ietf.org/doc/html/rfc2812#page-47 - (RFC 1459 is irrelevant here, as https://datatracker.ietf.org/doc/html/rfc1459#page-51 uses a different format) Closes #313. --- diff --git a/src/ngircd/irc-info.c b/src/ngircd/irc-info.c index 9a531bb0..7287f3ca 100644 --- a/src/ngircd/irc-info.c +++ b/src/ngircd/irc-info.c @@ -818,7 +818,7 @@ IRC_NAMES( CLIENT *Client, REQUEST *Req ) /* Now print all clients which are not in any channel */ c = Client_First(); - snprintf(rpl, sizeof(rpl), RPL_NAMREPLY_MSG, Client_ID(from), "*", "*"); + snprintf(rpl, sizeof(rpl), RPL_NAMREPLY_MSG, Client_ID(from), '*', "*"); while (c) { if (Client_Type(c) == CLIENT_USER && Channel_FirstChannelOf(c) == NULL @@ -830,11 +830,11 @@ IRC_NAMES( CLIENT *Client, REQUEST *Req ) strlcat(rpl, Client_ID(c), sizeof(rpl)); if (strlen(rpl) > COMMAND_LEN - CLIENT_NICK_LEN - 4) { - /* Line is gwoing too long, send now */ + /* Line is going too long, send now */ if (!IRC_WriteStrClient(from, "%s", rpl)) return DISCONNECTED; snprintf(rpl, sizeof(rpl), RPL_NAMREPLY_MSG, - Client_ID(from), "*", "*"); + Client_ID(from), '*', "*"); } } c = Client_Next(c); @@ -1500,6 +1500,8 @@ IRC_Send_NAMES(CLIENT * Client, CHANNEL * Chan) char str[COMMAND_LEN]; CL2CHAN *cl2chan; CLIENT *cl; + bool secret_channel; + char chan_symbol; assert(Client != NULL); assert(Chan != NULL); @@ -1514,10 +1516,13 @@ IRC_Send_NAMES(CLIENT * Client, CHANNEL * Chan) return CONNECTED; /* Secret channel? */ - if (!is_member && Channel_HasMode(Chan, 's')) + secret_channel = Channel_HasMode(Chan, 's'); + if (!is_member && secret_channel) return CONNECTED; - snprintf(str, sizeof(str), RPL_NAMREPLY_MSG, Client_ID(Client), "=", + chan_symbol = secret_channel ? '@' : '='; + + snprintf(str, sizeof(str), RPL_NAMREPLY_MSG, Client_ID(Client), chan_symbol, Channel_Name(Chan)); cl2chan = Channel_FirstMember(Chan); while (cl2chan) { @@ -1540,7 +1545,7 @@ IRC_Send_NAMES(CLIENT * Client, CHANNEL * Chan) if (!IRC_WriteStrClient(Client, "%s", str)) return DISCONNECTED; snprintf(str, sizeof(str), RPL_NAMREPLY_MSG, - Client_ID(Client), "=", + Client_ID(Client), chan_symbol, Channel_Name(Chan)); } } diff --git a/src/ngircd/messages.h b/src/ngircd/messages.h index 1bbfa699..5c33b35d 100644 --- a/src/ngircd/messages.h +++ b/src/ngircd/messages.h @@ -84,7 +84,7 @@ #define RPL_ENDOFEXCEPTLIST_MSG "349 %s %s :End of channel exception list" #define RPL_VERSION_MSG "351 %s %s-%s.%s %s :%s" #define RPL_WHOREPLY_MSG "352 %s %s %s %s %s %s %s :%d %s" -#define RPL_NAMREPLY_MSG "353 %s %s %s :" +#define RPL_NAMREPLY_MSG "353 %s %c %s :" #define RPL_LINKS_MSG "364 %s %s %s :%d %s" #define RPL_ENDOFLINKS_MSG "365 %s %s :End of LINKS list" #define RPL_ENDOFNAMES_MSG "366 %s %s :End of NAMES list"