[asterisk-commits] rmudgett: trunk r403544 - in /trunk: ./ main/sorcery.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Dec 9 12:32:59 CST 2013


Author: rmudgett
Date: Mon Dec  9 12:32:57 2013
New Revision: 403544

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=403544
Log:
sorcery: Eliminate shadowing a varaible that caused confusion.

* Eliminated shadowing of the __ast_sorcery_apply_config() name parameter
causing confusion.

* Fix potential crash from sorcery.conf user input in
__ast_sorcery_apply_config() if the user supplied a malformed config line
that is missing the sorcery object type name.

* Remove redundant test in __ast_sorcery_apply_config().  !config and
config == CONFIGS_STATUS_FILEMISSING are identical.
........

Merged revisions 403541 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    trunk/   (props changed)
    trunk/main/sorcery.c

Propchange: trunk/
------------------------------------------------------------------------------
--- branch-12-merged (original)
+++ branch-12-merged Mon Dec  9 12:32:57 2013
@@ -1,1 +1,1 @@
-/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-403290,403292-403398,403435,403458,403510,403527,403542
+/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-403290,403292-403398,403435,403458,403510,403527,403541-403542

Modified: trunk/main/sorcery.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/sorcery.c?view=diff&rev=403544&r1=403543&r2=403544
==============================================================================
--- trunk/main/sorcery.c (original)
+++ trunk/main/sorcery.c Mon Dec  9 12:32:57 2013
@@ -513,19 +513,21 @@
 	struct ast_variable *mapping;
 	int res = 0;
 
-	if (!config || (config == CONFIG_STATUS_FILEMISSING) || (config == CONFIG_STATUS_FILEINVALID)) {
+	if (!config || config == CONFIG_STATUS_FILEINVALID) {
 		return -1;
 	}
 
 	for (mapping = ast_variable_browse(config, name); mapping; mapping = mapping->next) {
 		RAII_VAR(char *, mapping_name, ast_strdup(mapping->name), ast_free);
 		RAII_VAR(char *, mapping_value, ast_strdup(mapping->value), ast_free);
-		char *options = mapping_name, *name = strsep(&options, "/");
-		char *data = mapping_value, *wizard = strsep(&data, ",");
+		char *options = mapping_name;
+		char *type = strsep(&options, "/");
+		char *data = mapping_value;
+		char *wizard = strsep(&data, ",");
 		unsigned int caching = 0;
 
-		/* If no wizard exists just skip, nothing we can do */
-		if (ast_strlen_zero(wizard)) {
+		/* If no object type or wizard exists just skip, nothing we can do */
+		if (ast_strlen_zero(type) || ast_strlen_zero(wizard)) {
 			continue;
 		}
 
@@ -535,7 +537,8 @@
 		}
 
 		/* Any error immediately causes us to stop */
-		if ((res = sorcery_apply_wizard_mapping(sorcery, name, module, wizard, data, caching))) {
+		if (sorcery_apply_wizard_mapping(sorcery, type, module, wizard, data, caching)) {
+			res = -1;
 			break;
 		}
 	}




More information about the asterisk-commits mailing list