diff options
author | Corey Farrell <git@cfware.com> | 2015-06-08 11:09:22 -0400 |
---|---|---|
committer | Corey Farrell <git@cfware.com> | 2015-06-08 11:09:22 -0400 |
commit | 55c8daf88b94f74e334ab246c51bdb7b469eedc4 (patch) | |
tree | 8c79fa393e6f2427929d2f89bf0bd4ee03b25a09 /apps | |
parent | 720251f2b80639324a37b2041997292d97858d39 (diff) |
Fix unsafe uses of ast_context pointers.
Although ast_context_find, ast_context_find_or_create and
ast_context_destroy perform locking of the contexts table,
any context pointer can become invalid at any time that the
contexts table is unlocked. This change adds locking around
all complete operations involving these functions.
Places where ast_context_find was followed by ast_context_destroy
have been replaced with calls ast_context_destroy_by_name.
ASTERISK-25094 #close
Reported by: Corey Farrell
Change-Id: I1866b6787730c9c4f3f836b6133ffe9c820734fa
Diffstat (limited to 'apps')
-rw-r--r-- | apps/app_meetme.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/apps/app_meetme.c b/apps/app_meetme.c index 907770e22..341014cea 100644 --- a/apps/app_meetme.c +++ b/apps/app_meetme.c @@ -7539,14 +7539,13 @@ static int sla_build_trunk(struct ast_config *cfg, const char *cat) ao2_unlock(trunk); if (!ast_strlen_zero(trunk->autocontext)) { - struct ast_context *context; - context = ast_context_find_or_create(NULL, NULL, trunk->autocontext, sla_registrar); - if (!context) { + if (!ast_context_find_or_create(NULL, NULL, trunk->autocontext, sla_registrar)) { ast_log(LOG_ERROR, "Failed to automatically find or create " "context '%s' for SLA!\n", trunk->autocontext); return -1; } - if (ast_add_extension2(context, 0 /* don't replace */, "s", 1, + + if (ast_add_extension(trunk->autocontext, 0 /* don't replace */, "s", 1, NULL, NULL, slatrunk_app, ast_strdup(trunk->name), ast_free_ptr, sla_registrar)) { ast_log(LOG_ERROR, "Failed to automatically create extension " "for trunk '%s'!\n", trunk->name); @@ -7715,17 +7714,16 @@ static int sla_build_station(struct ast_config *cfg, const char *cat) ao2_unlock(station); if (!ast_strlen_zero(station->autocontext)) { - struct ast_context *context; struct sla_trunk_ref *trunk_ref; - context = ast_context_find_or_create(NULL, NULL, station->autocontext, sla_registrar); - if (!context) { + + if (!ast_context_find_or_create(NULL, NULL, station->autocontext, sla_registrar)) { ast_log(LOG_ERROR, "Failed to automatically find or create " "context '%s' for SLA!\n", station->autocontext); return -1; } /* The extension for when the handset goes off-hook. * exten => station1,1,SLAStation(station1) */ - if (ast_add_extension2(context, 0 /* don't replace */, station->name, 1, + if (ast_add_extension(station->autocontext, 0 /* don't replace */, station->name, 1, NULL, NULL, slastation_app, ast_strdup(station->name), ast_free_ptr, sla_registrar)) { ast_log(LOG_ERROR, "Failed to automatically create extension " "for trunk '%s'!\n", station->name); @@ -7738,7 +7736,7 @@ static int sla_build_station(struct ast_config *cfg, const char *cat) snprintf(hint, sizeof(hint), "SLA:%s", exten); /* Extension for this line button * exten => station1_line1,1,SLAStation(station1_line1) */ - if (ast_add_extension2(context, 0 /* don't replace */, exten, 1, + if (ast_add_extension(station->autocontext, 0 /* don't replace */, exten, 1, NULL, NULL, slastation_app, ast_strdup(exten), ast_free_ptr, sla_registrar)) { ast_log(LOG_ERROR, "Failed to automatically create extension " "for trunk '%s'!\n", station->name); @@ -7746,7 +7744,7 @@ static int sla_build_station(struct ast_config *cfg, const char *cat) } /* Hint for this line button * exten => station1_line1,hint,SLA:station1_line1 */ - if (ast_add_extension2(context, 0 /* don't replace */, exten, PRIORITY_HINT, + if (ast_add_extension(station->autocontext, 0 /* don't replace */, exten, PRIORITY_HINT, NULL, NULL, hint, NULL, NULL, sla_registrar)) { ast_log(LOG_ERROR, "Failed to automatically create hint " "for trunk '%s'!\n", station->name); |