[asterisk-commits] russell: trunk r84169 - /trunk/main/cli.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Oct 1 09:55:11 CDT 2007


Author: russell
Date: Mon Oct  1 09:55:10 2007
New Revision: 84169

URL: http://svn.digium.com/view/asterisk?view=rev&rev=84169
Log:
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)

Modified:
    trunk/main/cli.c

Modified: trunk/main/cli.c
URL: http://svn.digium.com/view/asterisk/trunk/main/cli.c?view=diff&rev=84169&r1=84168&r2=84169
==============================================================================
--- trunk/main/cli.c (original)
+++ trunk/main/cli.c Mon Oct  1 09:55:10 2007
@@ -1407,16 +1407,14 @@
 		}
 		*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 {




More information about the asterisk-commits mailing list