summaryrefslogtreecommitdiff
path: root/pbx
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 /pbx
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 'pbx')
-rw-r--r--pbx/pbx_config.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c
index d85b901f9..5848e91d8 100644
--- a/pbx/pbx_config.c
+++ b/pbx/pbx_config.c
@@ -133,8 +133,6 @@ static char *complete_dialplan_remove_context(struct ast_cli_args *);
static char *handle_cli_dialplan_remove_context(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- struct ast_context *con;
-
switch (cmd) {
case CLI_INIT:
e->command = "dialplan remove context";
@@ -150,16 +148,11 @@ static char *handle_cli_dialplan_remove_context(struct ast_cli_entry *e, int cmd
return CLI_SHOWUSAGE;
}
- con = ast_context_find(a->argv[3]);
-
- if (!con) {
- ast_cli(a->fd, "There is no such context as '%s'\n",
- a->argv[3]);
- return CLI_SUCCESS;
+ if (ast_context_destroy_by_name(a->argv[3], NULL)) {
+ ast_cli(a->fd, "There is no such context as '%s'\n", a->argv[3]);
+ return CLI_SUCCESS;
} else {
- ast_context_destroy(con, registrar);
- ast_cli(a->fd, "Removing context '%s'\n",
- a->argv[3]);
+ ast_cli(a->fd, "Removed context '%s'\n", a->argv[3]);
return CLI_SUCCESS;
}
}