Skip to content
Snippets Groups Projects
Commit 9475dc94 authored by Matt Jordan's avatar Matt Jordan
Browse files

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
parent 7908ae49
Branches
Tags
No related merge requests found
...@@ -348,9 +348,18 @@ static void sorcery_config_reload(void *data, const struct ast_sorcery *sorcery, ...@@ -348,9 +348,18 @@ static void sorcery_config_reload(void *data, const struct ast_sorcery *sorcery,
static void *sorcery_config_open(const char *data) 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; 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))) { if (ast_strlen_zero(filename) || !(config = ao2_alloc_options(sizeof(*config) + strlen(filename) + 1, sorcery_config_destructor, AO2_ALLOC_OPT_LOCK_NOLOCK))) {
return NULL; return NULL;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment