summaryrefslogtreecommitdiff
path: root/apps/app_meetme.c
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2015-06-08 11:09:57 -0400
committerCorey Farrell <git@cfware.com>2015-06-08 11:09:57 -0400
commit80621ce3c5da5062f7e3efb42d6e8fcdd9caa3f6 (patch)
tree830f2bf1823901045bccffe224a858ba70b7a9e8 /apps/app_meetme.c
parent8785d0ccbfa1959d1ba6be8769e9d5356f3fef32 (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/app_meetme.c')
-rw-r--r--apps/app_meetme.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/apps/app_meetme.c b/apps/app_meetme.c
index e74ad7518..0c339d6ba 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);