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: https://origsvn.digium.com/svn/asterisk/trunk@160626 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Michelson
2008-12-03 18:37:46 +00:00
parent aa16330ce3
commit a53877b469
3 changed files with 23 additions and 9 deletions

View File

@@ -373,8 +373,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);
@@ -382,6 +383,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);