mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-25 06:00:36 +00:00 
			
		
		
		
	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: https://origsvn.digium.com/svn/asterisk/trunk@84169 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
		| @@ -1407,16 +1407,14 @@ static int __ast_cli_register(struct ast_cli_entry *e, struct ast_cli_entry *ed) | |||||||
| 		} | 		} | ||||||
| 		*dst++ = NULL; | 		*dst++ = NULL; | ||||||
| 	} | 	} | ||||||
| 	if (set_full_cmd(e)) |  | ||||||
| 		goto done; |  | ||||||
| 	AST_RWLIST_WRLOCK(&helpers); | 	AST_RWLIST_WRLOCK(&helpers); | ||||||
| 	 | 	 | ||||||
| 	if (find_cli(e->cmda, 1)) { | 	if (find_cli(e->cmda, 1)) { | ||||||
| 		ast_log(LOG_WARNING, "Command '%s' already registered (or something close enough)\n", e->_full_cmd); | 		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; | 		goto done; | ||||||
| 	} | 	} | ||||||
|  | 	if (set_full_cmd(e)) | ||||||
|  | 		goto done; | ||||||
| 	if (!ed) { | 	if (!ed) { | ||||||
| 		e->deprecated = 0; | 		e->deprecated = 0; | ||||||
| 	} else { | 	} else { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user