irc: fix crash when receiving a malformed message 324 (channel mode)

Thanks to Stuart Nevans Locke for reporting the issue.
v2.8-utf8proc
Sébastien Helleu 2020-02-08 20:24:50 +01:00
parent 39f2591cf5
commit 6f4f147d8e
2 changed files with 13 additions and 9 deletions

View File

@ -30,6 +30,7 @@ Bug fixes::
* core: flush stdout/stderr before forking in hook_process function (issue #1441)
* core: fix evaluation of condition with nested "if" (issue #1434)
* irc: fix crash when receiving a malformed message 324 (channel mode)
* irc: add nick changes in the hotlist (except self nick change)
* irc: case-insensitive comparison on incoming CTCP command, force upper case on CTCP replies (issue #1439)
* irc: fix memory leak when the channel topic is changed

View File

@ -224,17 +224,20 @@ irc_mode_channel_update (struct t_irc_server *server,
current_arg++;
if (pos[0] == chanmode)
{
chanmode_found = 1;
if (set_flag == '+')
if (!chanmode_found)
{
str_mode[0] = pos[0];
str_mode[1] = '\0';
strcat (new_modes, str_mode);
if (argument)
chanmode_found = 1;
if (set_flag == '+')
{
if (new_args[0])
strcat (new_args, " ");
strcat (new_args, argument);
str_mode[0] = pos[0];
str_mode[1] = '\0';
strcat (new_modes, str_mode);
if (argument)
{
if (new_args[0])
strcat (new_args, " ");
strcat (new_args, argument);
}
}
}
}