From 80621ce3c5da5062f7e3efb42d6e8fcdd9caa3f6 Mon Sep 17 00:00:00 2001 From: Corey Farrell Date: Mon, 8 Jun 2015 11:09:57 -0400 Subject: 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 --- apps/app_meetme.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'apps/app_meetme.c') 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); -- cgit v1.2.3