summaryrefslogtreecommitdiff
path: root/res/res_sorcery_config.c
diff options
context:
space:
mode:
authorMatt Jordan <mjordan@digium.com>2015-07-19 09:11:18 -0500
committerMatt Jordan <mjordan@digium.com>2015-07-19 09:11:18 -0500
commit9475dc9492bbb0921e27ac33398faaa81a6eae08 (patch)
treed16d60f543942ce0fa67f0582ebb9cf01cd2b7c0 /res/res_sorcery_config.c
parent7908ae49347919f4a9ecc4089a56f516c5562f5a (diff)
res/res_sorcery_config: Prevent crash from misconfigured sorcery.conf
Misconfiguring sorcery.conf with a 'config' wizard with no extra data will currently crash Asterisk on startup, as the wizard requires a comma delineated list to parse. This patch updates res_sorcery_config to check for the presence of the data before it starts manipulating it. Change-Id: I4c97512e8258bc82abe190627a9206c28f5d3847
Diffstat (limited to 'res/res_sorcery_config.c')
-rw-r--r--res/res_sorcery_config.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/res/res_sorcery_config.c b/res/res_sorcery_config.c
index b6ad0ccf5..092cc41c8 100644
--- a/res/res_sorcery_config.c
+++ b/res/res_sorcery_config.c
@@ -348,9 +348,18 @@ static void sorcery_config_reload(void *data, const struct ast_sorcery *sorcery,
static void *sorcery_config_open(const char *data)
{
- char *tmp = ast_strdupa(data), *filename = strsep(&tmp, ","), *option;
+ char *tmp;
+ char *filename;
+ char *option;
struct sorcery_config *config;
+ if (ast_strlen_zero(data)) {
+ return NULL;
+ }
+
+ tmp = ast_strdupa(data);
+ filename = strsep(&tmp, ",");
+
if (ast_strlen_zero(filename) || !(config = ao2_alloc_options(sizeof(*config) + strlen(filename) + 1, sorcery_config_destructor, AO2_ALLOC_OPT_LOCK_NOLOCK))) {
return NULL;
}