]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res/res_sorcery_config: Prevent crash from misconfigured sorcery.conf 30/930/1
authorMatt Jordan <mjordan@digium.com>
Sun, 19 Jul 2015 14:11:18 +0000 (09:11 -0500)
committerMatt Jordan <mjordan@digium.com>
Sun, 19 Jul 2015 14:11:18 +0000 (09:11 -0500)
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

res/res_sorcery_config.c

index b6ad0ccf5fe86e0e1d0da48675df25612dd7b59a..092cc41c8db4a19e4b5f666dcbe207be155d1bf4 100644 (file)
@@ -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;
        }