diff --git a/ChangeLog.asciidoc b/ChangeLog.asciidoc index 79f1191cf..39e13ef5e 100644 --- a/ChangeLog.asciidoc +++ b/ChangeLog.asciidoc @@ -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 diff --git a/src/plugins/relay/irc/relay-irc.c b/src/plugins/relay/irc/relay-irc.c index f210169d7..18131b4c1 100644 --- a/src/plugins/relay/irc/relay-irc.c +++ b/src/plugins/relay/irc/relay-irc.c @@ -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"); + } } } }