aboutsummaryrefslogtreecommitdiffstats
path: root/main/manager.c
diff options
context:
space:
mode:
authorbweschke <bweschke@f38db490-d61c-443f-a65b-d21fe96a405b>2008-10-18 02:18:33 +0000
committerbweschke <bweschke@f38db490-d61c-443f-a65b-d21fe96a405b>2008-10-18 02:18:33 +0000
commit8595eb4ab6f4d60835627933b11a774b4d0270da (patch)
tree547c7845a0cfb5ba8b0611de9a3b0b102e4d7c24 /main/manager.c
parenta882f145b1080e2bd3a1e43b8219ab2d912aa2dd (diff)
Using the GetVar handler in AMI is potentially dangerous (insta-crash [tm]) when you use a dialplan function that requires a channel and then you don't provide one or provide an invalid one in the Channel: parameter. We'll handle this situation exactly the same way it was handled in pbx.c back on r61766.
We'll create a bogus channel for the function call and destroy it when we're done. If we have trouble allocating the bogus channel then we're not going to try executing the function call at all and run the risk of crashing. (closes issue #13715) reported by: makoto patch by: bweschke git-svn-id: http://svn.digium.com/svn/asterisk/trunk@150817 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/manager.c')
-rw-r--r--main/manager.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/main/manager.c b/main/manager.c
index ce21757c6..a865e0fe0 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -1805,8 +1805,15 @@ static int action_getvar(struct mansession *s, const struct message *m)
}
if (varname[strlen(varname) - 1] == ')') {
-
- ast_func_read(c, (char *) varname, workspace, sizeof(workspace));
+ if (!c) {
+ c = ast_channel_alloc(0, 0, "", "", "", "", "", 0, "Bogus/%p", NULL);
+ if (c) {
+ ast_func_read(c, (char *) varname, workspace, sizeof(workspace));
+ ast_channel_free(c);
+ } else
+ ast_log(LOG_ERROR, "Unable to allocate bogus channel for variable substitution. Function results may be blank.\n");
+ } else
+ ast_func_read(c, (char *) varname, workspace, sizeof(workspace));
varval = workspace;
} else {
pbx_retrieve_variable(c, varname, &varval, workspace, sizeof(workspace), NULL);