diff options
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_agent.c | 17 | ||||
-rw-r--r-- | channels/chan_alsa.c | 6 | ||||
-rw-r--r-- | channels/chan_console.c | 3 | ||||
-rw-r--r-- | channels/chan_dahdi.c | 21 | ||||
-rw-r--r-- | channels/chan_gtalk.c | 6 | ||||
-rw-r--r-- | channels/chan_h323.c | 21 | ||||
-rw-r--r-- | channels/chan_iax2.c | 15 | ||||
-rw-r--r-- | channels/chan_jingle.c | 3 | ||||
-rw-r--r-- | channels/chan_mgcp.c | 6 | ||||
-rw-r--r-- | channels/chan_oss.c | 3 | ||||
-rw-r--r-- | channels/chan_phone.c | 5 | ||||
-rw-r--r-- | channels/chan_sip.c | 26 | ||||
-rw-r--r-- | channels/chan_skinny.c | 5 | ||||
-rw-r--r-- | channels/chan_unistim.c | 3 |
14 files changed, 120 insertions, 20 deletions
diff --git a/channels/chan_agent.c b/channels/chan_agent.c index 5f5afbd43..83dbd38e4 100644 --- a/channels/chan_agent.c +++ b/channels/chan_agent.c @@ -1117,8 +1117,21 @@ static int read_agent_config(int reload) if (!cfg) { ast_log(LOG_NOTICE, "No agent configuration found -- agent support disabled\n"); return 0; - } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) + } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { return -1; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "%s contains a parsing error. Aborting\n", config); + return 0; + } + if ((ucfg = ast_config_load("users.conf", config_flags))) { + if (ucfg == CONFIG_STATUS_FILEUNCHANGED) { + ucfg = NULL; + } else if (ucfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "users.conf contains a parsing error. Aborting\n"); + return 0; + } + } + AST_LIST_LOCK(&agents); AST_LIST_TRAVERSE(&agents, p, list) { p->dead = 1; @@ -1208,7 +1221,7 @@ static int read_agent_config(int reload) } v = v->next; } - if ((ucfg = ast_config_load("users.conf", config_flags)) && ucfg != CONFIG_STATUS_FILEUNCHANGED) { + if (ucfg) { genhasagent = ast_true(ast_variable_retrieve(ucfg, "general", "hasagent")); catname = ast_category_browse(ucfg, NULL); while(catname) { diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c index 9a6f7287c..66fecd564 100644 --- a/channels/chan_alsa.c +++ b/channels/chan_alsa.c @@ -857,8 +857,12 @@ static int load_module(void) strcpy(mohinterpret, "default"); - if (!(cfg = ast_config_load(config, config_flags))) + if (!(cfg = ast_config_load(config, config_flags))) { return AST_MODULE_LOAD_DECLINE; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "%s is in an invalid format. Aborting.\n", config); + return AST_MODULE_LOAD_DECLINE; + } v = ast_variable_browse(cfg, "general"); for (; v; v = v->next) { diff --git a/channels/chan_console.c b/channels/chan_console.c index 92777f5ea..3511e0bac 100644 --- a/channels/chan_console.c +++ b/channels/chan_console.c @@ -1400,6 +1400,9 @@ static int load_config(int reload) if (!(cfg = ast_config_load(config_file, config_flags))) { ast_log(LOG_NOTICE, "Unable to open configuration file %s!\n", config_file); return -1; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_NOTICE, "Config file %s has an invalid format\n", config_file); + return -1; } ao2_callback(pvts, OBJ_NODATA, pvt_mark_destroy_cb, NULL); diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index 5a9e1a510..25e76b5af 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -14567,13 +14567,28 @@ static int setup_dahdi(int reload) return 0; } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { ucfg = ast_config_load("users.conf", config_flags); - if (ucfg == CONFIG_STATUS_FILEUNCHANGED) + if (ucfg == CONFIG_STATUS_FILEUNCHANGED) { return 0; + } else if (ucfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "File users.conf cannot be parsed. Aborting.\n"); + return 0; + } ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); - cfg = ast_config_load(config, config_flags); + if ((cfg = ast_config_load(config, config_flags)) == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "File %s cannot be parsed. Aborting.\n", config); + ast_config_destroy(ucfg); + return 0; + } + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "File %s cannot be parsed. Aborting.\n", config); + return 0; } else { ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); - ucfg = ast_config_load("users.conf", config_flags); + if ((ucfg = ast_config_load("users.conf", config_flags)) == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "File users.conf cannot be parsed. Aborting.\n"); + ast_config_destroy(cfg); + return 0; + } } /* It's a little silly to lock it, but we mind as well just to be sure */ diff --git a/channels/chan_gtalk.c b/channels/chan_gtalk.c index 76b4f9ad1..4a11b56a8 100644 --- a/channels/chan_gtalk.c +++ b/channels/chan_gtalk.c @@ -1869,8 +1869,12 @@ static int gtalk_load_config(void) struct ast_flags config_flags = { 0 }; cfg = ast_config_load(GOOGLE_CONFIG, config_flags); - if (!cfg) + if (!cfg) { return 0; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", GOOGLE_CONFIG); + return 0; + } /* Copy the default jb config over global_jbconf */ memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf)); diff --git a/channels/chan_h323.c b/channels/chan_h323.c index fc0c7f3c0..36f8cd5eb 100644 --- a/channels/chan_h323.c +++ b/channels/chan_h323.c @@ -2816,13 +2816,28 @@ static int reload_config(int is_reload) return 1; } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { ucfg = ast_config_load("users.conf", config_flags); - if (ucfg == CONFIG_STATUS_FILEUNCHANGED) + if (ucfg == CONFIG_STATUS_FILEUNCHANGED) { return 0; + } else if (ucfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file users.conf is in an invalid format. Aborting.\n"); + return 0; + } ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); - cfg = ast_config_load(config, config_flags); + if ((cfg = ast_config_load(config, config_flags))) { + ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config); + ast_config_destroy(ucfg); + return 0; + } + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config); + return 0; } else { ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); - ucfg = ast_config_load("users.conf", config_flags); + if ((ucfg = ast_config_load("users.conf", config_flags)) == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file users.conf is in an invalid format. Aborting.\n"); + ast_config_destroy(cfg); + return 0; + } } if (is_reload) { diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 31d9ccf2e..32ebe341b 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -11010,10 +11010,21 @@ static int set_config(char *config_file, int reload) return 0; /* Otherwise we need to reread both files */ ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); - cfg = ast_config_load(config_file, config_flags); + if ((cfg = ast_config_load(config_file, config_flags)) == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config_file); + ast_config_destroy(ucfg); + return 0; + } + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config_file); + return 0; } else { /* iax.conf changed, gotta reread users.conf, too */ ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); - ucfg = ast_config_load("users.conf", config_flags); + if ((ucfg = ast_config_load("users.conf", config_flags)) == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file users.conf is in an invalid format. Aborting.\n"); + ast_config_destroy(cfg); + return 0; + } } if (reload) { diff --git a/channels/chan_jingle.c b/channels/chan_jingle.c index 628461887..d239fd717 100644 --- a/channels/chan_jingle.c +++ b/channels/chan_jingle.c @@ -1736,8 +1736,9 @@ static int jingle_load_config(void) struct ast_flags config_flags = { 0 }; cfg = ast_config_load(JINGLE_CONFIG, config_flags); - if (!cfg) + if (!cfg || cfg == CONFIG_STATUS_FILEINVALID) { return 0; + } /* Copy the default jb config over global_jbconf */ memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf)); diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c index a5c54d4b9..644e7b787 100644 --- a/channels/chan_mgcp.c +++ b/channels/chan_mgcp.c @@ -4120,8 +4120,12 @@ static int reload_config(int reload) if (!cfg) { ast_log(LOG_NOTICE, "Unable to load config %s, MGCP disabled\n", config); return 0; - } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) + } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { return 0; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config); + return 0; + } memset(&bindaddr, 0, sizeof(bindaddr)); dtmfmode = 0; diff --git a/channels/chan_oss.c b/channels/chan_oss.c index b3c29c031..125fa156d 100644 --- a/channels/chan_oss.c +++ b/channels/chan_oss.c @@ -1434,6 +1434,9 @@ static int load_module(void) if (!(cfg = ast_config_load(config, config_flags))) { ast_log(LOG_NOTICE, "Unable to load config %s\n", config); return AST_MODULE_LOAD_DECLINE; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config); + return AST_MODULE_LOAD_DECLINE; } do { diff --git a/channels/chan_phone.c b/channels/chan_phone.c index 5ac54694d..d6030bbf1 100644 --- a/channels/chan_phone.c +++ b/channels/chan_phone.c @@ -1346,7 +1346,10 @@ static int load_module(void) int txgain = DEFAULT_GAIN, rxgain = DEFAULT_GAIN; /* default gain 1.0 */ struct ast_flags config_flags = { 0 }; - cfg = ast_config_load(config, config_flags); + if ((cfg = ast_config_load(config, config_flags)) == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config); + return AST_MODULE_LOAD_DECLINE; + } /* We *must* have a config file otherwise stop immediately */ if (!cfg) { diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 865b98f63..ea1a0e327 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -21220,14 +21220,29 @@ static int reload_config(enum channelreloadreason reason) return -1; } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { ucfg = ast_config_load("users.conf", config_flags); - if (ucfg == CONFIG_STATUS_FILEUNCHANGED) + if (ucfg == CONFIG_STATUS_FILEUNCHANGED) { return 1; + } else if (ucfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Contents of users.conf are invalid and cannot be parsed\n"); + return 1; + } /* Must reread both files, because one changed */ ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); - cfg = ast_config_load(config, config_flags); + if ((cfg = ast_config_load(config, config_flags)) == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Contents of %s are invalid and cannot be parsed\n", config); + ast_config_destroy(ucfg); + return 1; + } + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Contents of %s are invalid and cannot be parsed\n", config); + return 1; } else { ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); - ucfg = ast_config_load("users.conf", config_flags); + if ((ucfg = ast_config_load("users.conf", config_flags)) == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Contents of users.conf are invalid and cannot be parsed\n"); + ast_config_destroy(cfg); + return 1; + } } /* Initialize tcp sockets */ @@ -21996,7 +22011,10 @@ static int reload_config(enum channelreloadreason reason) /* Load the list of manual NOTIFY types to support */ if (notify_types) ast_config_destroy(notify_types); - notify_types = ast_config_load(notify_config, config_flags); + if ((notify_types = ast_config_load(notify_config, config_flags)) == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Contents of %s are invalid and cannot be parsed.\n", notify_config); + notify_types = NULL; + } /* Done, tell the manager */ manager_event(EVENT_FLAG_SYSTEM, "ChannelReload", "ChannelType: SIP\r\nReloadReason: %s\r\nRegistry_Count: %d\r\nPeer_Count: %d\r\n", channelreloadreason2txt(reason), registry_count, peer_count); diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index 9ab38521d..b25d492b9 100644 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -6210,7 +6210,10 @@ static int reload_config(void) ast_log(LOG_WARNING, "Unable to get hostname, Skinny disabled\n"); return 0; } - cfg = ast_config_load(config, config_flags); + if ((cfg = ast_config_load(config, config_flags)) == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config); + return 0; + } /* We *must* have a config file otherwise stop immediately */ if (!cfg) { diff --git a/channels/chan_unistim.c b/channels/chan_unistim.c index a605c6be7..48a41fc7a 100644 --- a/channels/chan_unistim.c +++ b/channels/chan_unistim.c @@ -5304,6 +5304,9 @@ static int reload_config(void) if (!cfg) { ast_log(LOG_ERROR, "Unable to load config %s\n", config); return -1; + } else if (cfg == CONFIG_STATUS_FILEINVALID) { + ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config); + return -1; } /* Copy the default jb config over global_jbconf */ |