aboutsummaryrefslogtreecommitdiffstats
path: root/main/cli.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-10-01 14:55:10 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-10-01 14:55:10 +0000
commitfae8b164a81eb15af9f685262cf8cfecfa760cae (patch)
tree6538319ce959f9f282cf8b24cfbae83e80fd9cb0 /main/cli.c
parentd4c3816decb6b11de305ef9df8759d04b71b2d31 (diff)
Don't set the full command string until after verifying that there is not
another CLI command with the same command text registered. This prevents a crash if someone accidentally calls ast_cli_register() on the same CLI command data twice. This also fixes a small bug where the helpers list would get unlocked without being locked if building the full command failed. (closes issue #10858, reported by jamesgolovich, patched by me) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@84169 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/cli.c')
-rw-r--r--main/cli.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/main/cli.c b/main/cli.c
index f6988b8b0..7e7514aba 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -1407,16 +1407,14 @@ static int __ast_cli_register(struct ast_cli_entry *e, struct ast_cli_entry *ed)
}
*dst++ = NULL;
}
- if (set_full_cmd(e))
- goto done;
AST_RWLIST_WRLOCK(&helpers);
if (find_cli(e->cmda, 1)) {
ast_log(LOG_WARNING, "Command '%s' already registered (or something close enough)\n", e->_full_cmd);
- ast_free(e->_full_cmd);
- e->_full_cmd = NULL;
goto done;
}
+ if (set_full_cmd(e))
+ goto done;
if (!ed) {
e->deprecated = 0;
} else {