[asterisk-commits] twilson: trunk r157818 - in /trunk: cdr/ channels/ main/ pbx/ res/ res/ais/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Nov 19 13:25:14 CST 2008


Author: twilson
Date: Wed Nov 19 13:25:14 2008
New Revision: 157818

URL: http://svn.digium.com/view/asterisk?view=rev&rev=157818
Log:
Fix checking for CONFIG_STATUS_FILEINVALID so that modules don't crash upon trying to parse an invalid config

Modified:
    trunk/cdr/cdr_adaptive_odbc.c
    trunk/cdr/cdr_csv.c
    trunk/cdr/cdr_custom.c
    trunk/cdr/cdr_manager.c
    trunk/cdr/cdr_odbc.c
    trunk/cdr/cdr_pgsql.c
    trunk/cdr/cdr_radius.c
    trunk/cdr/cdr_sqlite3_custom.c
    trunk/cdr/cdr_tds.c
    trunk/channels/chan_skinny.c
    trunk/channels/chan_usbradio.c
    trunk/channels/chan_vpb.cc
    trunk/channels/iax2-provision.c
    trunk/channels/misdn_config.c
    trunk/main/logger.c
    trunk/main/xmldoc.c
    trunk/pbx/pbx_dundi.c
    trunk/res/ais/evt.c
    trunk/res/res_clialiases.c

Modified: trunk/cdr/cdr_adaptive_odbc.c
URL: http://svn.digium.com/view/asterisk/trunk/cdr/cdr_adaptive_odbc.c?view=diff&rev=157818&r1=157817&r2=157818
==============================================================================
--- trunk/cdr/cdr_adaptive_odbc.c (original)
+++ trunk/cdr/cdr_adaptive_odbc.c Wed Nov 19 13:25:14 2008
@@ -97,7 +97,7 @@
 	struct ast_flags config_flags = { 0 }; /* Part of our config comes from the database */
 
 	cfg = ast_config_load(CONFIG, config_flags);
-	if (!cfg) {
+	if (!cfg || cfg == CONFIG_STATUS_FILEINVALID) {
 		ast_log(LOG_WARNING, "Unable to load " CONFIG ".  No adaptive ODBC CDRs.\n");
 		return -1;
 	}

Modified: trunk/cdr/cdr_csv.c
URL: http://svn.digium.com/view/asterisk/trunk/cdr/cdr_csv.c?view=diff&rev=157818&r1=157817&r2=157818
==============================================================================
--- trunk/cdr/cdr_csv.c (original)
+++ trunk/cdr/cdr_csv.c Wed Nov 19 13:25:14 2008
@@ -100,7 +100,7 @@
 	loguniqueid = 0;
 	loguserfield = 0;
 
-	if (!(cfg = ast_config_load(config, config_flags))) {
+	if (!(cfg = ast_config_load(config, config_flags)) || cfg == CONFIG_STATUS_FILEINVALID) {
 		ast_log(LOG_WARNING, "unable to load config: %s\n", config);
 		return 0;
 	} else if (cfg == CONFIG_STATUS_FILEUNCHANGED)

Modified: trunk/cdr/cdr_custom.c
URL: http://svn.digium.com/view/asterisk/trunk/cdr/cdr_custom.c?view=diff&rev=157818&r1=157817&r2=157818
==============================================================================
--- trunk/cdr/cdr_custom.c (original)
+++ trunk/cdr/cdr_custom.c Wed Nov 19 13:25:14 2008
@@ -66,6 +66,11 @@
 
 	if ((cfg = ast_config_load("cdr_custom.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
 		return 0;
+
+	if (cfg == CONFIG_STATUS_FILEINVALID) {
+		ast_log(LOG_ERROR, "Invalid config file\n");
+		return 1;
+	}
 
 	strcpy(format, "");
 	strcpy(master, "");

Modified: trunk/cdr/cdr_manager.c
URL: http://svn.digium.com/view/asterisk/trunk/cdr/cdr_manager.c?view=diff&rev=157818&r1=157817&r2=157818
==============================================================================
--- trunk/cdr/cdr_manager.c (original)
+++ trunk/cdr/cdr_manager.c Wed Nov 19 13:25:14 2008
@@ -61,6 +61,11 @@
 	cfg = ast_config_load(CONF_FILE, config_flags);
 	if (cfg == CONFIG_STATUS_FILEUNCHANGED)
 		return 0;
+
+	if (cfg == CONFIG_STATUS_FILEINVALID) {
+		ast_log(LOG_ERROR, "Config file '%s' could not be parsed\n", CONF_FILE);
+		return 1;
+	}
 
 	if (reload && customfields) {
 		ast_free(customfields);

Modified: trunk/cdr/cdr_odbc.c
URL: http://svn.digium.com/view/asterisk/trunk/cdr/cdr_odbc.c?view=diff&rev=157818&r1=157817&r2=157818
==============================================================================
--- trunk/cdr/cdr_odbc.c (original)
+++ trunk/cdr/cdr_odbc.c Wed Nov 19 13:25:14 2008
@@ -161,7 +161,7 @@
 
 	do {
 		cfg = ast_config_load(config_file, config_flags);
-		if (!cfg) {
+		if (!cfg || cfg == CONFIG_STATUS_FILEINVALID) {
 			ast_log(LOG_WARNING, "cdr_odbc: Unable to load config for ODBC CDR's: %s\n", config_file);
 			res = AST_MODULE_LOAD_DECLINE;
 			break;
@@ -228,7 +228,7 @@
 		}
 	} while (0);
 
-	if (cfg && cfg != CONFIG_STATUS_FILEUNCHANGED)
+	if (cfg && cfg != CONFIG_STATUS_FILEUNCHANGED && cfg != CONFIG_STATUS_FILEINVALID)
 		ast_config_destroy(cfg);
 	return res;
 }

Modified: trunk/cdr/cdr_pgsql.c
URL: http://svn.digium.com/view/asterisk/trunk/cdr/cdr_pgsql.c?view=diff&rev=157818&r1=157817&r2=157818
==============================================================================
--- trunk/cdr/cdr_pgsql.c (original)
+++ trunk/cdr/cdr_pgsql.c Wed Nov 19 13:25:14 2008
@@ -370,7 +370,7 @@
 	struct ast_config *cfg;
 	struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
 
-	if ((cfg = ast_config_load(config, config_flags)) == NULL) {
+	if ((cfg = ast_config_load(config, config_flags)) == NULL || cfg == CONFIG_STATUS_FILEINVALID) {
 		ast_log(LOG_WARNING, "Unable to load config for PostgreSQL CDR's: %s\n", config);
 		return -1;
 	} else if (cfg == CONFIG_STATUS_FILEUNCHANGED)

Modified: trunk/cdr/cdr_radius.c
URL: http://svn.digium.com/view/asterisk/trunk/cdr/cdr_radius.c?view=diff&rev=157818&r1=157817&r2=157818
==============================================================================
--- trunk/cdr/cdr_radius.c (original)
+++ trunk/cdr/cdr_radius.c Wed Nov 19 13:25:14 2008
@@ -228,7 +228,7 @@
 	int res;
 	const char *tmp;
 
-	if ((cfg = ast_config_load(cdr_config, config_flags))) {
+	if ((cfg = ast_config_load(cdr_config, config_flags)) && cfg != CONFIG_STATUS_FILEINVALID) {
 		ast_set2_flag(&global_flags, ast_true(ast_variable_retrieve(cfg, "radius", "usegmtime")), RADIUS_FLAG_USEGMTIME);
 		ast_set2_flag(&global_flags, ast_true(ast_variable_retrieve(cfg, "radius", "loguniqueid")), RADIUS_FLAG_LOGUNIQUEID);
 		ast_set2_flag(&global_flags, ast_true(ast_variable_retrieve(cfg, "radius", "loguserfield")), RADIUS_FLAG_LOGUSERFIELD);

Modified: trunk/cdr/cdr_sqlite3_custom.c
URL: http://svn.digium.com/view/asterisk/trunk/cdr/cdr_sqlite3_custom.c?view=diff&rev=157818&r1=157817&r2=157818
==============================================================================
--- trunk/cdr/cdr_sqlite3_custom.c (original)
+++ trunk/cdr/cdr_sqlite3_custom.c Wed Nov 19 13:25:14 2008
@@ -158,7 +158,7 @@
 	struct ast_variable *mappingvar;
 	const char *tmp;
 
-	if (!(cfg = ast_config_load(config_file, config_flags))) {
+	if (!(cfg = ast_config_load(config_file, config_flags)) || cfg == CONFIG_STATUS_FILEINVALID) {
 		if (reload)
 			ast_log(LOG_WARNING, "Failed to reload configuration file.\n");
 		else

Modified: trunk/cdr/cdr_tds.c
URL: http://svn.digium.com/view/asterisk/trunk/cdr/cdr_tds.c?view=diff&rev=157818&r1=157817&r2=157818
==============================================================================
--- trunk/cdr/cdr_tds.c (original)
+++ trunk/cdr/cdr_tds.c Wed Nov 19 13:25:14 2008
@@ -426,7 +426,7 @@
 	struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
 
 	cfg = ast_config_load(config, config_flags);
-	if (!cfg) {
+	if (!cfg || cfg == CONFIG_STATUS_FILEINVALID) {
 		ast_log(LOG_NOTICE, "Unable to load TDS config for CDRs: %s\n", config);
 		return 0;
 	} else if (cfg == CONFIG_STATUS_FILEUNCHANGED)

Modified: trunk/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_skinny.c?view=diff&rev=157818&r1=157817&r2=157818
==============================================================================
--- trunk/channels/chan_skinny.c (original)
+++ trunk/channels/chan_skinny.c Wed Nov 19 13:25:14 2008
@@ -6477,7 +6477,7 @@
   	cfg = ast_config_load(config, config_flags);
   
   	/* We *must* have a config file otherwise stop immediately */
-  	if (!cfg) {
+  	if (!cfg || cfg == CONFIG_STATUS_FILEINVALID) {
  		ast_log(LOG_NOTICE, "Unable to load config %s, Skinny disabled.\n", config);
   		return -1;
   	}

Modified: trunk/channels/chan_usbradio.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_usbradio.c?view=diff&rev=157818&r1=157817&r2=157818
==============================================================================
--- trunk/channels/chan_usbradio.c (original)
+++ trunk/channels/chan_usbradio.c Wed Nov 19 13:25:14 2008
@@ -3510,7 +3510,7 @@
 	o->txctcssadj = 200;
 	o->rxsquelchadj = 500;
 	o->devstr[0] = 0;
-	if (cfg1) {
+	if (cfg1 && cfg1 != CONFIG_STATUS_FILEINVALID) {
 		for (v = ast_variable_browse(cfg1, o->name); v; v = v->next) {
 	
 			M_START((char *)v->name, (char *)v->value);
@@ -3942,9 +3942,9 @@
 
 	/* load config file */
 #ifdef	NEW_ASTERISK
-	if (!(cfg = ast_config_load(config,zeroflag))) {
+	if (!(cfg = ast_config_load(config,zeroflag)) || cfg == CONFIG_STATUS_FILEINVALID) {
 #else
-	if (!(cfg = ast_config_load(config))) {
+	if (!(cfg = ast_config_load(config))) || cfg == CONFIG_STATUS_FILEINVALID {
 #endif
 		ast_log(LOG_NOTICE, "Unable to load config %s\n", config);
 		return AST_MODULE_LOAD_DECLINE;

Modified: trunk/channels/chan_vpb.cc
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_vpb.cc?view=diff&rev=157818&r1=157817&r2=157818
==============================================================================
--- trunk/channels/chan_vpb.cc (original)
+++ trunk/channels/chan_vpb.cc Wed Nov 19 13:25:14 2008
@@ -2714,7 +2714,7 @@
 	cfg = ast_config_load(config, config_flags);
 
 	/* We *must* have a config file otherwise stop immediately */
-	if (!cfg) {
+	if (!cfg || cfg == CONFIG_STATUS_FILEINVALID) {
 		ast_log(LOG_ERROR, "Unable to load config %s\n", config);
 		return AST_MODULE_LOAD_DECLINE;
 	}  

Modified: trunk/channels/iax2-provision.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/iax2-provision.c?view=diff&rev=157818&r1=157817&r2=157818
==============================================================================
--- trunk/channels/iax2-provision.c (original)
+++ trunk/channels/iax2-provision.c Wed Nov 19 13:25:14 2008
@@ -493,7 +493,7 @@
 		iax_provision_init();
 	
 	cfg = ast_config_load2("iaxprov.conf", "chan_iax2", config_flags);
-	if (cfg != NULL && cfg != CONFIG_STATUS_FILEUNCHANGED) {
+	if (cfg != NULL && cfg != CONFIG_STATUS_FILEUNCHANGED && cfg != CONFIG_STATUS_FILEINVALID) {
 		/* Mark all as dead.  No need for locking */
 		cur = templates;
 		while(cur) {

Modified: trunk/channels/misdn_config.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn_config.c?view=diff&rev=157818&r1=157817&r2=157818
==============================================================================
--- trunk/channels/misdn_config.c (original)
+++ trunk/channels/misdn_config.c Wed Nov 19 13:25:14 2008
@@ -1101,8 +1101,8 @@
 	struct ast_variable *v;
 	struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
 
-	if (!(cfg = ast_config_load2(config, "chan_misdn", config_flags))) {
-		ast_log(LOG_WARNING, "missing file: misdn.conf\n");
+	if (!(cfg = ast_config_load2(config, "chan_misdn", config_flags)) || cfg == CONFIG_STATUS_FILEINVALID) {
+		ast_log(LOG_WARNING, "missing or invalid file: misdn.conf\n");
 		return -1;
 	} else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
 		return 0;

Modified: trunk/main/logger.c
URL: http://svn.digium.com/view/asterisk/trunk/main/logger.c?view=diff&rev=157818&r1=157817&r2=157818
==============================================================================
--- trunk/main/logger.c (original)
+++ trunk/main/logger.c Wed Nov 19 13:25:14 2008
@@ -326,7 +326,7 @@
 	const char *s;
 	struct ast_flags config_flags = { 0 };
 
-	if (!(cfg = ast_config_load2("logger.conf", "logger", config_flags)))
+	if (!(cfg = ast_config_load2("logger.conf", "logger", config_flags)) || cfg == CONFIG_STATUS_FILEINVALID)
 		return;
 
 	/* delete our list of log channels */

Modified: trunk/main/xmldoc.c
URL: http://svn.digium.com/view/asterisk/trunk/main/xmldoc.c?view=diff&rev=157818&r1=157817&r2=157818
==============================================================================
--- trunk/main/xmldoc.c (original)
+++ trunk/main/xmldoc.c Wed Nov 19 13:25:14 2008
@@ -1721,7 +1721,7 @@
 	/* setup default XML documentation language */
 	snprintf(documentation_language, sizeof(documentation_language), default_documentation_language);
 
-	if ((cfg = ast_config_load2("asterisk.conf", "" /* core can't reload */, cnfflags))) {
+	if ((cfg = ast_config_load2("asterisk.conf", "" /* core can't reload */, cnfflags)) && cfg != CONFIG_STATUS_FILEINVALID) {
 		for (var = ast_variable_browse(cfg, "options"); var; var = var->next) {
 			if (!strcasecmp(var->name, "documentation_language")) {
 				if (!ast_strlen_zero(var->value)) {

Modified: trunk/pbx/pbx_dundi.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx/pbx_dundi.c?view=diff&rev=157818&r1=157817&r2=157818
==============================================================================
--- trunk/pbx/pbx_dundi.c (original)
+++ trunk/pbx/pbx_dundi.c Wed Nov 19 13:25:14 2008
@@ -4558,7 +4558,7 @@
 	int globalpcmodel = 0;
 	dundi_eid testeid;
 
-	if (!(cfg = ast_config_load(config_file, config_flags))) {
+	if (!(cfg = ast_config_load(config_file, config_flags)) || cfg == CONFIG_STATUS_FILEINVALID) {
 		ast_log(LOG_ERROR, "Unable to load config %s\n", config_file);
 		return -1;
 	} else if (cfg == CONFIG_STATUS_FILEUNCHANGED)

Modified: trunk/res/ais/evt.c
URL: http://svn.digium.com/view/asterisk/trunk/res/ais/evt.c?view=diff&rev=157818&r1=157817&r2=157818
==============================================================================
--- trunk/res/ais/evt.c (original)
+++ trunk/res/ais/evt.c Wed Nov 19 13:25:14 2008
@@ -475,7 +475,7 @@
 	const char *cat = NULL;
 	struct ast_flags config_flags = { 0 };
 
-	if (!(cfg = ast_config_load(filename, config_flags)))
+	if (!(cfg = ast_config_load(filename, config_flags)) || cfg == CONFIG_STATUS_FILEINVALID)
 		return;
 
 	while ((cat = ast_category_browse(cfg, cat))) {

Modified: trunk/res/res_clialiases.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_clialiases.c?view=diff&rev=157818&r1=157817&r2=157818
==============================================================================
--- trunk/res/res_clialiases.c (original)
+++ trunk/res/res_clialiases.c Wed Nov 19 13:25:14 2008
@@ -190,7 +190,7 @@
 	struct cli_alias *alias;
 	struct ast_variable *v, *v1;
 
-	if (!(cfg = ast_config_load(config_file, config_flags))) {
+	if (!(cfg = ast_config_load(config_file, config_flags)) || cfg == CONFIG_STATUS_FILEINVALID) {
 		ast_log(LOG_ERROR, "res_clialiases configuration file '%s' not found\n", config_file);
 		return;
 	} else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {




More information about the asterisk-commits mailing list