irc: fix send of empty JOIN when connecting to a server with only parted channels (closes #1638)

This commit is contained in:
Sébastien Helleu 2021-09-03 13:43:07 +02:00
parent 6fc6166cfe
commit 5fb7ebdfce
3 changed files with 12 additions and 2 deletions

View File

@ -45,6 +45,7 @@ Bug fixes::
* core: fix decoding of attributes in basic ANSI colors (issue #1678)
* api: fix function string_match with joker in the string if multiple words matched in input string
* irc: fix send of empty JOIN when connecting to a server with only parted channels (issue #1638)
* irc: fix SASL authentication when AUTHENTICATE message is received with a server name (issue #1679)
* irc: remove unneeded message about Diffie-Hellman shared secret exchange during SSL connection to server (issue #857)
* irc: escape/unescape IRC message tags values (issue #1654)

View File

@ -5519,6 +5519,8 @@ irc_server_autojoin_create_buffers (struct t_irc_server *server)
*
* #channel1,#channel2,#channel3 key1,key2
*
* Returns NULL if no channels have been found.
*
* Note: result must be freed after use.
*/
@ -5527,6 +5529,7 @@ irc_server_build_autojoin (struct t_irc_server *server)
{
struct t_irc_channel *ptr_channel;
char **channels_with_key, **channels_others, **keys;
int num_channels;
channels_with_key = NULL;
channels_others = NULL;
@ -5542,6 +5545,8 @@ irc_server_build_autojoin (struct t_irc_server *server)
if (!keys)
goto error;
num_channels = 0;
for (ptr_channel = server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
@ -5569,9 +5574,13 @@ irc_server_build_autojoin (struct t_irc_server *server)
ptr_channel->name,
-1);
}
num_channels++;
}
}
if (num_channels == 0)
goto error;
/*
* concatenate channels_with_key + channels_others + keys
* into channels_with_key

View File

@ -1088,7 +1088,7 @@ TEST(IrcServerConnected, BuildAutojoin)
server_recv (":server 001 alice");
WEE_TEST_STR("", irc_server_build_autojoin (ptr_server));
POINTERS_EQUAL(NULL, irc_server_build_autojoin (ptr_server));
/* join one channel */
server_recv (":alice!user@host JOIN #test1");
@ -1096,7 +1096,7 @@ TEST(IrcServerConnected, BuildAutojoin)
/* simulate a "parted" channel */
ptr_server->channels->part = 1;
WEE_TEST_STR("", irc_server_build_autojoin (ptr_server));
POINTERS_EQUAL(NULL, irc_server_build_autojoin (ptr_server));
/* restore "part" flag */
ptr_server->channels->part = 0;