Menu

#62 obscure modcmd bind alias bug from loss of scoped variable

Unstable (example)
open
nobody
None
5
2013-12-24
2013-12-24
No

Hi..

Just tracked down a really annoying hard-to-pin bug in x3, noticed it's upstream in srvx too:

in svccmd_invoke_argv new_argv is declared scoped in a code block for aliases but argv is assigned it, then continued to be used later. Causes crashes/weird behavior when aliasing, esp with -O2:

/msg o3 bind x3 helpserv *helpserv.helpserv foo $1
.helpserv
-O3- is an unknown command.
(that space is random garbage, or a segfault under some OS/conditions)

Merry Xmas,
-Rubin

~~~~~~
commit ab26b178f9529d1a74957dc6d41c3da21b78d53d
Author: Alex Schumann rubin@afternet.org
Date: Mon Dec 23 15:52:26 2013 -0800

fix bug using local scoped char outside scope

diff --git a/src/modcmd.c b/src/modcmd.c
index 84cb36d..9276a54 100644
--- a/src/modcmd.c
+++ b/src/modcmd.c
@@ -691,6 +691,7 @@ svccmd_invoke_argv(struct userNode user, struct service service, struct chanNo
struct svccmd cmd;
unsigned int cmd_arg, perms, flags, options, result;
char channel_name[CHANNELLEN+1];
+ char
new_argv[MAXNUMPARAMS]; / for aliases /

 options = (server_qualified ? SVCCMD_QUALIFIED : 0) | SVCCMD_DEBIT | SVCCMD_NOISY;
 /* Find the command argument. */

@@ -754,7 +755,6 @@ svccmd_invoke_argv(struct userNode user, struct service service, struct chanNo

 /* Expand the alias arguments, if there are any. */
 if (cmd->alias.used) {
  • char *new_argv[MAXNUMPARAMS];
    int res;

     res = svccmd_expand_alias(cmd, user, argc, argv, new_argv);
    

    ~~~~~~~~~~

Discussion


Log in to post a comment.