On Sun, Jun 12, 2016 at 06:54:28AM +0200, Jeremie Courreges-Anglas wrote:

> Marcus Glocker <[email protected]> writes:
> 
> > On Sun, Jun 05, 2016 at 08:04:26AM +0200, Marcus Glocker wrote:
> >
> >> ICB has been designed for a user always need to be joined to a group.
> >> With the irssi-icb module you can break this rule currently by running
> >> the '/window close' command and therefore crash irssi simply:
> >> 
> >>    /window close
> >>    /j 2
> >>    Segmentation fault (core dumped)
> >> 
> >> icb-channels.c:icb_change_channel() will try to compare the current
> >> group with the new group on the next join command, and in case of a
> >> previous '/window close' irssi has already destroyed our group and
> >> freed the reference to it.  Hence icb_change_channel() is comparing
> >> a group string against a freed memory address and segfaults.
> >> 
> >> Attached patch disables the '/window close' command for ICB
> >> connections, since this just shouldn't be supported.
> >
> > This is an improved version of the last diff.  It still allows one to
> > close windows for private queries but just returns an error when you
> > try to close your ICB group window.
> 
> I would prefer if /wc would just disconnect from the server, there
> is no point in keeping the connection around since as you say a user is

Well, I find /wc still useful to close old private queries on icb, which
will work now with the updated diff.

> supposed to always be joined to a group.  Are you sure that only /wc
> could get irssi confused? That said...

I was thinking about this was well, but except /wc nothing else came in
mind to me yet.  Maybe when I send this patch upstream they'll have a
further think also.
 
> > I will also try to push this one upstream.
> >
> > Anyone brave around to ok this? :-)
> 
> Your diff fixes a crash which would be very annoying for people that
> also use irssi for other purposes than icb, thus I think it's a valuable
> addition.

Count me in :-)  I trapped in to this several times ...

> ok jca@, but please also unbind cmd_window in icb_commands_deinit, as in
> the updated patch below.

Yep, good point.  Thanks for your feedback, much appreciated.

> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/net/irssi-icb/Makefile,v
> retrieving revision 1.39
> diff -u -p -r1.39 Makefile
> --- Makefile  16 Mar 2016 21:19:38 -0000      1.39
> +++ Makefile  12 Jun 2016 04:50:01 -0000
> @@ -7,6 +7,7 @@ GH_PROJECT=   irssi-icb
>  GH_COMMIT=   8f7060835355d5f620a5d3b75a45336ab8efefd9
>  
>  DISTNAME=    irssi-icb-0.16pre20160307
> +REVISION=    0
>  
>  CATEGORIES=     net
>  
> Index: patches/patch-src_core_icb-commands_c
> ===================================================================
> RCS file: patches/patch-src_core_icb-commands_c
> diff -N patches/patch-src_core_icb-commands_c
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-src_core_icb-commands_c     12 Jun 2016 04:49:13 -0000
> @@ -0,0 +1,50 @@
> +$OpenBSD$
> +--- src/core/icb-commands.c.orig     Mon Mar  7 09:54:15 2016
> ++++ src/core/icb-commands.c  Sun Jun 12 06:49:09 2016
> +@@ -19,6 +19,7 @@
> + */
> + 
> + #include "module.h"
> ++#include "../fe-common/core/fe-windows.h"
> + 
> + #include "icb-commands.h"
> + #include "icb-servers.h"
> +@@ -101,6 +102,24 @@ static void cmd_beep(const char *data, ICB_SERVER_REC 
> +     }
> + }
> + 
> ++static void cmd_window(const char *data, ICB_SERVER_REC *server)
> ++{
> ++    CMD_ICB_SERVER(server);
> ++
> ++    /*
> ++     * Return an error in case the '/window close' command has been
> ++     * issued in your active ICB group window.  In ICB you always
> ++     * need to be joined to one group.
> ++     */
> ++    if (*data != '\0' && (*data == 'c' || *data == 'C')) {
> ++            if (!strcmp(window_get_active_name(active_win),
> ++                server->group->name)) {
> ++                    cmd_return_error(CMDERR_ILLEGAL_PROTO);
> ++                    signal_stop();
> ++            }
> ++    }
> ++}
> ++
> + void icb_commands_init(void)
> + {
> +     char **cmd;
> +@@ -116,6 +135,7 @@ void icb_commands_init(void)
> +         command_bind_icb("kick", NULL, (SIGNAL_FUNC) cmd_boot);
> +         command_bind_icb("g", NULL, (SIGNAL_FUNC) cmd_group);
> +         command_bind_icb("beep", NULL, (SIGNAL_FUNC) cmd_beep);
> ++        command_bind_icb("window", NULL, (SIGNAL_FUNC) cmd_window);
> + 
> +     command_set_options("connect", "+icbnet");
> + }
> +@@ -134,4 +154,5 @@ void icb_commands_deinit(void)
> +         command_unbind("kick", (SIGNAL_FUNC) cmd_boot);
> +         command_unbind("g", (SIGNAL_FUNC) cmd_group);
> +         command_unbind("beep", (SIGNAL_FUNC) cmd_beep);
> ++        command_unbind("window", (SIGNAL_FUNC) cmd_window);
> + }

Reply via email to