fix bug 2994 (off by 1 error)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4404 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.2-netsec
Anthony Minessale II 21 years ago
parent ab7bf9d4fd
commit 8708f19e39

39
pbx.c

@ -3837,7 +3837,7 @@ int ast_explicit_goto(struct ast_channel *chan, const char *context, const char
strncpy(chan->context, context, sizeof(chan->context) - 1); strncpy(chan->context, context, sizeof(chan->context) - 1);
if (exten && !ast_strlen_zero(exten)) if (exten && !ast_strlen_zero(exten))
strncpy(chan->exten, exten, sizeof(chan->context) - 1); strncpy(chan->exten, exten, sizeof(chan->context) - 1);
if (priority) if(priority > -1)
chan->priority = priority; chan->priority = priority;
return 0; return 0;
} }
@ -3869,7 +3869,7 @@ int ast_async_goto(struct ast_channel *chan, const char *context, const char *ex
ast_explicit_goto(tmpchan, ast_explicit_goto(tmpchan,
(context && !ast_strlen_zero(context)) ? context : chan->context, (context && !ast_strlen_zero(context)) ? context : chan->context,
(exten && !ast_strlen_zero(exten)) ? exten : chan->exten, (exten && !ast_strlen_zero(exten)) ? exten : chan->exten,
priority ? priority : chan->priority); priority - 1);
/* Masquerade into temp channel */ /* Masquerade into temp channel */
ast_channel_masquerade(tmpchan, chan); ast_channel_masquerade(tmpchan, chan);
@ -5420,18 +5420,28 @@ int ast_context_verify_includes(struct ast_context *con)
static int __ast_goto_if_exists(struct ast_channel *chan, char* context, char *exten, int priority, int async) static int __ast_goto_if_exists(struct ast_channel *chan, char* context, char *exten, int priority, int async)
{ {
int (*goto_func)(struct ast_channel *chan, const char *context, const char *exten, int priority) = async ? ast_async_goto : ast_explicit_goto; int (*goto_func)(struct ast_channel *chan, const char *context, const char *exten, int priority) = NULL;
if(chan) { if(chan) {
if(ast_exists_extension(chan,
context ? context : chan->context, if (async) {
exten ? exten : chan->exten, goto_func = ast_async_goto;
priority ? priority : chan->priority, } else {
chan->cid.cid_num)) { goto_func = ast_explicit_goto;
priority--;
if(priority < 0)
priority = 0;
}
if (ast_exists_extension(chan,
context ? context : chan->context,
exten ? exten : chan->exten,
priority,
chan->cid.cid_num)) {
return goto_func(chan, return goto_func(chan,
context ? context : chan->context, context ? context : chan->context,
exten ? exten : chan->exten, exten ? exten : chan->exten,
(priority ? priority : chan->priority) - 1); priority);
} else } else
return -3; return -3;
} }
@ -5501,12 +5511,7 @@ int ast_parseable_goto(struct ast_channel *chan, const char *goto_string)
ipri = chan->priority + (ipri * mode); ipri = chan->priority + (ipri * mode);
/* This channel is currently in the PBX */ /* This channel is currently in the PBX */
if (context && !ast_strlen_zero(context)) ast_explicit_goto(chan, context, exten, ipri - 1);
strncpy(chan->context, context, sizeof(chan->context) - 1);
if (exten && !ast_strlen_zero(exten))
strncpy(chan->exten, exten, sizeof(chan->context) - 1);
chan->priority = ipri - 1;
ast_cdr_update(chan); ast_cdr_update(chan);
return 0; return 0;

Loading…
Cancel
Save