relay: fix crash when an IRC "MODE" command is received from client without arguments

This commit is contained in:
Sébastien Helleu 2014-08-09 16:14:44 +02:00
parent a538a9c08e
commit ddd7a85f2d
2 changed files with 45 additions and 43 deletions

View File

@ -171,6 +171,8 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
* python: fix read of return value for callbacks returning an integer
in Python 2.x (closes #125)
* python: fix interpreter used after unload of a script
* relay: fix crash when an IRC "MODE" command is received from client without
arguments
* relay: fix number of bytes sent/received on 32-bit systems
* relay: fix crash when closing relay buffers (closes #57, closes #78)
* relay: check pointers received in hdata command to prevent crashes with bad

View File

@ -1633,58 +1633,58 @@ relay_irc_recv (struct t_relay_client *client, const char *data)
weechat_hashtable_set (hash_redirect, "signal", str_signal);
if (weechat_strcasecmp (irc_command, "mode") == 0)
{
if (irc_argc == 1)
redirect_msg = 1;
weechat_hashtable_set (hash_redirect, "pattern",
"mode_channel");
if (irc_argc > 0)
{
if (irc_argc == 1)
redirect_msg = 1;
weechat_hashtable_set (hash_redirect, "pattern",
"mode_channel");
weechat_hashtable_set (hash_redirect, "string",
irc_argv[0]);
}
snprintf (str_server_channel,
sizeof (str_server_channel),
"%s,%s",
client->protocol_args,
irc_argv[0]);
info = weechat_info_get ("irc_is_channel",
str_server_channel);
if (info && (strcmp (info, "1") == 0))
{
/* command "MODE #channel ..." */
if (irc_argc == 2)
snprintf (str_server_channel,
sizeof (str_server_channel),
"%s,%s",
client->protocol_args,
irc_argv[0]);
info = weechat_info_get ("irc_is_channel",
str_server_channel);
if (info && (strcmp (info, "1") == 0))
{
if ((strcmp (irc_argv[1], "b") == 0)
|| (strcmp (irc_argv[1], "+b") == 0))
/* command "MODE #channel ..." */
if (irc_argc == 2)
{
redirect_msg = 1;
weechat_hashtable_set (hash_redirect, "pattern",
"mode_channel_ban");
}
else if ((strcmp (irc_argv[1], "e") == 0)
|| (strcmp (irc_argv[1], "+e") == 0))
{
redirect_msg = 1;
weechat_hashtable_set (hash_redirect, "pattern",
"mode_channel_ban_exception");
}
else if ((strcmp (irc_argv[1], "I") == 0)
|| (strcmp (irc_argv[1], "+I") == 0))
{
redirect_msg = 1;
weechat_hashtable_set (hash_redirect, "pattern",
"mode_channel_invite");
if ((strcmp (irc_argv[1], "b") == 0)
|| (strcmp (irc_argv[1], "+b") == 0))
{
redirect_msg = 1;
weechat_hashtable_set (hash_redirect, "pattern",
"mode_channel_ban");
}
else if ((strcmp (irc_argv[1], "e") == 0)
|| (strcmp (irc_argv[1], "+e") == 0))
{
redirect_msg = 1;
weechat_hashtable_set (hash_redirect, "pattern",
"mode_channel_ban_exception");
}
else if ((strcmp (irc_argv[1], "I") == 0)
|| (strcmp (irc_argv[1], "+I") == 0))
{
redirect_msg = 1;
weechat_hashtable_set (hash_redirect, "pattern",
"mode_channel_invite");
}
}
}
}
else
{
/* command "MODE nick ..." */
if (irc_argc == 1)
else
{
redirect_msg = 1;
weechat_hashtable_set (hash_redirect, "pattern",
"mode_user");
/* command "MODE nick ..." */
if (irc_argc == 1)
{
redirect_msg = 1;
weechat_hashtable_set (hash_redirect, "pattern",
"mode_user");
}
}
}
}