From 619de7f01222e36aac4bd997678dcf2bc15afe70 Mon Sep 17 00:00:00 2001 From: Mark Michelson <mmichelson@digium.com> Date: Tue, 11 Dec 2012 20:53:34 +0000 Subject: [PATCH] Fix crash that can occur if CLI registration fails for an aliased command. A recent memory leak fix in main/cli.c causes an ast_cli_entry's command field to be freed and NULLed if ast_cli_register() fails. res_clialiases was ignoring the return value of ast_cli_register() and was then passing the NULL command off to a a hash function. This resulted in a crash. The fix is not to ignore the erroneous return value. If ast_cli_register() fails, then we do not continue trying to process the current alias. ........ Merged revisions 377840 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 377842 from http://svn.asterisk.org/svn/asterisk/branches/10 ........ Merged revisions 377843 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@377844 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- res/res_clialiases.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/res/res_clialiases.c b/res/res_clialiases.c index d9c4088bc8..17a847648e 100644 --- a/res/res_clialiases.c +++ b/res/res_clialiases.c @@ -218,7 +218,10 @@ static void load_config(int reload) alias->cli_entry.command = alias->alias; alias->cli_entry.usage = "Aliased CLI Command\n"; - ast_cli_register(&alias->cli_entry); + if (ast_cli_register(&alias->cli_entry)) { + ao2_ref(alias, -1); + continue; + } ao2_link(cli_aliases, alias); ast_verb(2, "Aliased CLI command '%s' to '%s'\n", v1->name, v1->value); ao2_ref(alias, -1); -- GitLab