diff options
author | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-12-03 18:41:28 +0000 |
---|---|---|
committer | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-12-03 18:41:28 +0000 |
commit | 4cf05e590461894a02ff84b2a69225a443b7085a (patch) | |
tree | 2cdbb12ea32c95f31e878373c0118cf990488903 /apps | |
parent | e21070b05ecf37e3825c6bdb3b886fdf66b1d629 (diff) |
Merged revisions 160626 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
........
r160626 | mmichelson | 2008-12-03 12:37:46 -0600 (Wed, 03 Dec 2008) | 16 lines
Add some safety measures when using gosub, especially when using the options
for app_dial and app_queue to run a gosub when the call is answered.
* Check for the existence of the gosub target in gosub_exec. If it is nonexistent,
then this will cause errors when we attempt to actually run the gosub, including
a definite memory leak and potential crashes. Return an error in this situation
* Check the return value of pbx_exec in app_dial and app_queue before attempting
to actually run the gosub routine. If there was an error, we should not attempt
to run the gosub.
* Change a '|' to a ',' in app_queue.
* Add some extra curly braces where they had been missing previously.
(closes issue #13548)
Reported by: fiddur
........
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@160627 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r-- | apps/app_dial.c | 7 | ||||
-rw-r--r-- | apps/app_queue.c | 11 | ||||
-rw-r--r-- | apps/app_stack.c | 13 |
3 files changed, 23 insertions, 8 deletions
diff --git a/apps/app_dial.c b/apps/app_dial.c index 52d8ed31e..0021015bd 100644 --- a/apps/app_dial.c +++ b/apps/app_dial.c @@ -1832,12 +1832,15 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags if (gosub_args) { res = pbx_exec(peer, theapp, gosub_args); - ast_pbx_run(peer); + if (!res) { + ast_pbx_run(peer); + } ast_free(gosub_args); if (option_debug) ast_log(LOG_DEBUG, "Gosub exited with status %d\n", res); - } else + } else { ast_log(LOG_ERROR, "Could not Allocate string for Gosub arguments -- Gosub Call Aborted!\n"); + } res = 0; } else { diff --git a/apps/app_queue.c b/apps/app_queue.c index 80579a11e..875943580 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -3771,7 +3771,7 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno)); gosub_args = NULL; } - *gosub_argstart = '|'; + *gosub_argstart = ','; } else { if (asprintf(&gosub_args, "%s,s,1", gosubexec) < 0) { ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno)); @@ -3780,14 +3780,15 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce } if (gosub_args) { res = pbx_exec(peer, app, gosub_args); - ast_pbx_run(peer); + if (!res) { + ast_pbx_run(peer); + } free(gosub_args); if (option_debug) ast_log(LOG_DEBUG, "Gosub exited with status %d\n", res); - } else + } else { ast_log(LOG_ERROR, "Could not Allocate string for Gosub arguments -- Gosub Call Aborted!\n"); - - res = 0; + } } else { ast_log(LOG_ERROR, "Could not find application Gosub\n"); res = -1; diff --git a/apps/app_stack.c b/apps/app_stack.c index a6333d8d4..cd6ed5521 100644 --- a/apps/app_stack.c +++ b/apps/app_stack.c @@ -272,8 +272,9 @@ static int gosub_exec(struct ast_channel *chan, void *data) /* Create the return address, but don't save it until we know that the Gosub destination exists */ newframe = gosub_allocate_frame(chan->context, chan->exten, chan->priority + 1, args2.argc); - if (!newframe) + if (!newframe) { return -1; + } if (ast_parseable_goto(chan, label)) { ast_log(LOG_ERROR, "Gosub address is invalid: '%s'\n", (char *)data); @@ -281,6 +282,16 @@ static int gosub_exec(struct ast_channel *chan, void *data) return -1; } + if (!ast_exists_extension(chan, chan->context, chan->exten, chan->priority, chan->cid.cid_num)) { + ast_log(LOG_ERROR, "Attempt to reach a non-existent destination for gosub: (Context:%s, Extension:%s, Priority:%d)\n", + chan->context, chan->exten, chan->priority); + ast_copy_string(chan->context, newframe->context, sizeof(chan->context)); + ast_copy_string(chan->exten, newframe->extension, sizeof(chan->exten)); + chan->priority = newframe->priority; + ast_free(newframe); + return -1; + } + /* Now that we know for certain that we're going to a new location, set our arguments */ for (i = 0; i < args2.argc; i++) { snprintf(argname, sizeof(argname), "ARG%d", i + 1); |