From ddd7a85f2dc0f335abe727699db50554818e6af4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sat, 9 Aug 2014 16:14:44 +0200 Subject: relay: fix crash when an IRC "MODE" command is received from client without arguments --- src/plugins/relay/irc/relay-irc.c | 82 +++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 41 deletions(-) (limited to 'src/plugins/relay') 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,60 +1633,60 @@ 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"); + 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 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)) + } + else + { + /* command "MODE nick ..." */ + if (irc_argc == 1) { redirect_msg = 1; weechat_hashtable_set (hash_redirect, "pattern", - "mode_channel_invite"); + "mode_user"); } } } - else - { - /* command "MODE nick ..." */ - if (irc_argc == 1) - { - redirect_msg = 1; - weechat_hashtable_set (hash_redirect, "pattern", - "mode_user"); - } - } } else if (weechat_strcasecmp (irc_command, "ison") == 0) { -- cgit v1.2.3