Summary: | ASTERISK-13159: [patch] Incorrect jump to extension | ||
Reporter: | Daniel A. Veiga (dveiga) | Labels: | |
Date Opened: | 2008-12-02 20:46:34.000-0600 | Date Closed: | 2010-01-04 12:30:54.000-0600 |
Priority: | Major | Regression? | No |
Status: | Closed/Complete | Components: | Applications/General |
Versions: | Frequency of Occurrence | ||
Related Issues: | |||
Environment: | Attachments: | ( 0) pbx.c.patch | |
Description: | When calling Background() application, function pbx_builtin_background() is called. Inside it, I believe there's a bug when comparing the channel context with the one used as a parameter. Where it says "if (args.context != chan->context && res)" it should say "if ( strcmp(args.context, chan->context) && res)". I just explained it because in this simple case I think its easier than sending a patch, but I can send the patch file if it helps. | ||
Comments: | By: Joshua C. Colp (jcolp) 2008-12-10 16:16:34.000-0600 The code is working as it should. It is used in combination with the 'm' extension and specified context. If no context is specified then args.context is set to chan->context so the code you mentioned is not executed in that scenario. By: Daniel A. Veiga (dveiga) 2009-01-14 11:48:56.000-0600 Sory for the time taken to reopen the issue, but I was out on hollidays :). I do not agree with your explanation. Code at pbx_builtin_background() in main/pbx.c reads: AST_DECLARE_APP_ARGS(args, AST_APP_ARG(filename); AST_APP_ARG(options); AST_APP_ARG(lang); AST_APP_ARG(context); ); Using these definitions at include/asterisk/app.h: #define AST_APP_ARG(name) char *name #define AST_DECLARE_APP_ARGS(name, arglist) AST_DEFINE_APP_ARGS_TYPE(, arglist) name #define AST_DEFINE_APP_ARGS_TYPE(type, arglist) struct type { \ unsigned int argc; \ char *argv[0]; \ arglist \ } I expand the macros at main/pbx.c just to show that what's defined there is equivalent to: struct type { unsigned int argc; char *argv[0]; char *filename; char *options; char *lang; char *context; } args; Leaving this code aside for a moment, the 'data' parameter that the function pbx_builtin_background() receives is first duplicated using ast_strdupa(), then it is parsed using a macro called AST_STANDARD_APP_ARGS(). This macro is defined in include/asterisk/app.h as follows: #define AST_STANDARD_APP_ARGS(args, parse) args.argc = ast_app_separate_args(parse, ',', args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0]))) Function ast_app_separate_args() fills in the args structure with the values retrieved from the duplicated 'data' string. After the function call ALL POINTERS IN THE STRUCTURE ABOVE POINT TO DIFFERENT OFFSETS OF THE STRING ALLOCATED WITH ast_strdupa()! So the comparison between args.context (that as I said point somewhere into the string allocated with ast_strdupa) and chan->context (that points into the chan structure) will NEVER be true! What we should do is compare if the name of the context received as a parameter is the same as the name of the current context, calling strcmp(args.context, chan->context) I hope you get my point, otherwise yust let me know. Thanks ... Daniel PS: I've attached a proposed patch for pbx.c By: Joshua C. Colp (jcolp) 2009-01-14 13:25:34.000-0600 There is additional code after the AST_STANDARD_APP_ARGS call: if (ast_strlen_zero(args.context)) args.context = chan->context; So that if no context was specified in the arguments then it points to chan->context - this would cause the comparison to be true. By: Daniel A. Veiga (dveiga) 2009-01-14 19:04:49.000-0600 Ok, I understand that if NO context is passed, the comparison will be true. The problem arrises when we do specify the context and it is the same as the current context. I suppose your next question is obvious "Why are you specifying the context if it is the same as the current one?" Well someone changed the behavior of the Background() function some time ago. Before the change, the extensions checked when the user dialed in some numbers where ALWAYS in the current context. After that change, if the current context was reached using a GoSub command, the extensions checked by default are not in the current context but in the context the GoSub command was executed. For example [from-internal] exten => s,1,GoSub(get-number,s,1) .... [get-number] exten => s,1,Set(GetNumberResult=0) exten => s,n,Background(some-sound-file) exten => s,n,Return() exten => _X,1,Set(GetNumberResult=${EXTEN}) exten => _X,n,Return() With the new behavior when the user presses a digit, it WILL NOT junp to the _X extension because it will search the 'from-internal' context. To make it work, you should replace the background like with this one: exten => s,n,Background(some-sound-file,,,get-number) There is a special comment about this change in the description of the Background commnd at http://www.voip-info.org/wiki-Asterisk+cmd+Background. Please check the 'Background() inside a macro' section. This is why I had to specify the context even if its equal to the current one, and I can“t make it work without the 'strcmp'. Note that the proposed patch works in both situations (no context specified and same context specified). Thanks for your patience ... Daniel By: Digium Subversion (svnbot) 2009-01-22 09:13:34.000-0600 Repository: asterisk Revision: 170050 U branches/1.4/main/pbx.c ------------------------------------------------------------------------ r170050 | file | 2009-01-22 09:13:34 -0600 (Thu, 22 Jan 2009) | 6 lines Do a string comparison instead of pointer comparison since some people specify the context they are actually in as an argument to get around some funkiness. (closes issue ASTERISK-13159) Reported by: dveiga Patches: pbx.c.patch uploaded by dveiga (license 665) ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=170050 By: Digium Subversion (svnbot) 2009-01-22 09:14:28.000-0600 Repository: asterisk Revision: 170051 _U trunk/ U trunk/main/pbx.c ------------------------------------------------------------------------ r170051 | file | 2009-01-22 09:14:27 -0600 (Thu, 22 Jan 2009) | 13 lines Merged revisions 170050 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r170050 | file | 2009-01-22 11:13:56 -0400 (Thu, 22 Jan 2009) | 6 lines Do a string comparison instead of pointer comparison since some people specify the context they are actually in as an argument to get around some funkiness. (closes issue ASTERISK-13159) Reported by: dveiga Patches: pbx.c.patch uploaded by dveiga (license 665) ........ ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=170051 By: Digium Subversion (svnbot) 2009-01-22 09:15:13.000-0600 Repository: asterisk Revision: 170052 _U branches/1.6.0/ U branches/1.6.0/main/pbx.c ------------------------------------------------------------------------ r170052 | file | 2009-01-22 09:15:13 -0600 (Thu, 22 Jan 2009) | 20 lines Merged revisions 170051 via svnmerge from https://origsvn.digium.com/svn/asterisk/trunk ................ r170051 | file | 2009-01-22 11:14:50 -0400 (Thu, 22 Jan 2009) | 13 lines Merged revisions 170050 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r170050 | file | 2009-01-22 11:13:56 -0400 (Thu, 22 Jan 2009) | 6 lines Do a string comparison instead of pointer comparison since some people specify the context they are actually in as an argument to get around some funkiness. (closes issue ASTERISK-13159) Reported by: dveiga Patches: pbx.c.patch uploaded by dveiga (license 665) ........ ................ ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=170052 By: Digium Subversion (svnbot) 2009-01-22 09:15:50.000-0600 Repository: asterisk Revision: 170053 _U branches/1.6.1/ U branches/1.6.1/main/pbx.c ------------------------------------------------------------------------ r170053 | file | 2009-01-22 09:15:50 -0600 (Thu, 22 Jan 2009) | 20 lines Merged revisions 170051 via svnmerge from https://origsvn.digium.com/svn/asterisk/trunk ................ r170051 | file | 2009-01-22 11:14:50 -0400 (Thu, 22 Jan 2009) | 13 lines Merged revisions 170050 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r170050 | file | 2009-01-22 11:13:56 -0400 (Thu, 22 Jan 2009) | 6 lines Do a string comparison instead of pointer comparison since some people specify the context they are actually in as an argument to get around some funkiness. (closes issue ASTERISK-13159) Reported by: dveiga Patches: pbx.c.patch uploaded by dveiga (license 665) ........ ................ ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=170053 By: Digium Subversion (svnbot) 2009-05-07 18:41:12 Repository: asterisk Revision: 193119 U branches/1.4/main/pbx.c ------------------------------------------------------------------------ r193119 | tilghman | 2009-05-07 18:41:11 -0500 (Thu, 07 May 2009) | 19 lines Fix Background within a Macro for FreePBX. If the single digit DTMF is an extension in the specified context, then go there and signal no DTMF. Otherwise, we should exit with that DTMF. If we're in Macro, we'll exit and seek that DTMF as the beginning of an extension in the Macro's calling context. If we're not in Macro, then we'll simply seek that extension in the calling context. Previously, someone complained about the behavior as it related to the interior of a Gosub routine, and the fix (ASTERISK-13159) inadvertently broke FreePBX (ASTERISK-13929). This change should fix both of these situations, but with the possible incompatibility that if a single digit extension does not exist (but a longer extension COULD have matched), it would have previously gone immediately to the "i" extension, but will now need to wait for a timeout. (closes issue ASTERISK-13929) Reported by: p_lindheimer Patches: 20090420__bug14940.diff.txt uploaded by tilghman (license 14) Tested by: p_lindheimer ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=193119 By: Digium Subversion (svnbot) 2009-05-07 18:42:29 Repository: asterisk Revision: 193120 _U trunk/ U trunk/main/pbx.c ------------------------------------------------------------------------ r193120 | tilghman | 2009-05-07 18:42:29 -0500 (Thu, 07 May 2009) | 26 lines Merged revisions 193119 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r193119 | tilghman | 2009-05-07 18:41:11 -0500 (Thu, 07 May 2009) | 19 lines Fix Background within a Macro for FreePBX. If the single digit DTMF is an extension in the specified context, then go there and signal no DTMF. Otherwise, we should exit with that DTMF. If we're in Macro, we'll exit and seek that DTMF as the beginning of an extension in the Macro's calling context. If we're not in Macro, then we'll simply seek that extension in the calling context. Previously, someone complained about the behavior as it related to the interior of a Gosub routine, and the fix (ASTERISK-13159) inadvertently broke FreePBX (ASTERISK-13929). This change should fix both of these situations, but with the possible incompatibility that if a single digit extension does not exist (but a longer extension COULD have matched), it would have previously gone immediately to the "i" extension, but will now need to wait for a timeout. (closes issue ASTERISK-13929) Reported by: p_lindheimer Patches: 20090420__bug14940.diff.txt uploaded by tilghman (license 14) Tested by: p_lindheimer ........ ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=193120 By: Digium Subversion (svnbot) 2009-05-07 18:43:24 Repository: asterisk Revision: 193121 _U branches/1.6.0/ U branches/1.6.0/main/pbx.c ------------------------------------------------------------------------ r193121 | tilghman | 2009-05-07 18:43:23 -0500 (Thu, 07 May 2009) | 33 lines Merged revisions 193120 via svnmerge from https://origsvn.digium.com/svn/asterisk/trunk ................ r193120 | tilghman | 2009-05-07 18:42:28 -0500 (Thu, 07 May 2009) | 26 lines Merged revisions 193119 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r193119 | tilghman | 2009-05-07 18:41:11 -0500 (Thu, 07 May 2009) | 19 lines Fix Background within a Macro for FreePBX. If the single digit DTMF is an extension in the specified context, then go there and signal no DTMF. Otherwise, we should exit with that DTMF. If we're in Macro, we'll exit and seek that DTMF as the beginning of an extension in the Macro's calling context. If we're not in Macro, then we'll simply seek that extension in the calling context. Previously, someone complained about the behavior as it related to the interior of a Gosub routine, and the fix (ASTERISK-13159) inadvertently broke FreePBX (ASTERISK-13929). This change should fix both of these situations, but with the possible incompatibility that if a single digit extension does not exist (but a longer extension COULD have matched), it would have previously gone immediately to the "i" extension, but will now need to wait for a timeout. (closes issue ASTERISK-13929) Reported by: p_lindheimer Patches: 20090420__bug14940.diff.txt uploaded by tilghman (license 14) Tested by: p_lindheimer ........ ................ ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=193121 By: Digium Subversion (svnbot) 2009-05-07 18:44:21 Repository: asterisk Revision: 193122 _U branches/1.6.1/ U branches/1.6.1/main/pbx.c ------------------------------------------------------------------------ r193122 | tilghman | 2009-05-07 18:44:20 -0500 (Thu, 07 May 2009) | 33 lines Merged revisions 193120 via svnmerge from https://origsvn.digium.com/svn/asterisk/trunk ................ r193120 | tilghman | 2009-05-07 18:42:28 -0500 (Thu, 07 May 2009) | 26 lines Merged revisions 193119 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r193119 | tilghman | 2009-05-07 18:41:11 -0500 (Thu, 07 May 2009) | 19 lines Fix Background within a Macro for FreePBX. If the single digit DTMF is an extension in the specified context, then go there and signal no DTMF. Otherwise, we should exit with that DTMF. If we're in Macro, we'll exit and seek that DTMF as the beginning of an extension in the Macro's calling context. If we're not in Macro, then we'll simply seek that extension in the calling context. Previously, someone complained about the behavior as it related to the interior of a Gosub routine, and the fix (ASTERISK-13159) inadvertently broke FreePBX (ASTERISK-13929). This change should fix both of these situations, but with the possible incompatibility that if a single digit extension does not exist (but a longer extension COULD have matched), it would have previously gone immediately to the "i" extension, but will now need to wait for a timeout. (closes issue ASTERISK-13929) Reported by: p_lindheimer Patches: 20090420__bug14940.diff.txt uploaded by tilghman (license 14) Tested by: p_lindheimer ........ ................ ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=193122 By: Digium Subversion (svnbot) 2009-05-07 18:44:38 Repository: asterisk Revision: 193123 _U branches/1.6.2/ U branches/1.6.2/main/pbx.c ------------------------------------------------------------------------ r193123 | tilghman | 2009-05-07 18:44:38 -0500 (Thu, 07 May 2009) | 33 lines Merged revisions 193120 via svnmerge from https://origsvn.digium.com/svn/asterisk/trunk ................ r193120 | tilghman | 2009-05-07 18:42:28 -0500 (Thu, 07 May 2009) | 26 lines Merged revisions 193119 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r193119 | tilghman | 2009-05-07 18:41:11 -0500 (Thu, 07 May 2009) | 19 lines Fix Background within a Macro for FreePBX. If the single digit DTMF is an extension in the specified context, then go there and signal no DTMF. Otherwise, we should exit with that DTMF. If we're in Macro, we'll exit and seek that DTMF as the beginning of an extension in the Macro's calling context. If we're not in Macro, then we'll simply seek that extension in the calling context. Previously, someone complained about the behavior as it related to the interior of a Gosub routine, and the fix (ASTERISK-13159) inadvertently broke FreePBX (ASTERISK-13929). This change should fix both of these situations, but with the possible incompatibility that if a single digit extension does not exist (but a longer extension COULD have matched), it would have previously gone immediately to the "i" extension, but will now need to wait for a timeout. (closes issue ASTERISK-13929) Reported by: p_lindheimer Patches: 20090420__bug14940.diff.txt uploaded by tilghman (license 14) Tested by: p_lindheimer ........ ................ ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=193123 By: Digium Subversion (svnbot) 2010-01-04 12:19:01.000-0600 Repository: asterisk Revision: 237405 U branches/1.4/include/asterisk/channel.h U branches/1.4/main/pbx.c U branches/1.4/res/res_agi.c ------------------------------------------------------------------------ r237405 | tilghman | 2010-01-04 12:19:00 -0600 (Mon, 04 Jan 2010) | 16 lines Add a flag to disable the Background behavior, for AGI users. This is in a section of code that relates to two other issues, namely issue ASTERISK-13159 and issue ASTERISK-13929), one of which was the behavior of Background when called with a context argument that matched the current context. This fix broke FreePBX, however, in a post-Dial situation. Needless to say, this is an extremely difficult collision of several different issues. While the use of an exception flag is ugly, fixing all of the issues linked is rather difficult (although if someone would like to propose a better solution, we're happy to entertain that suggestion). (closes issue ASTERISK-15306) Reported by: rickead2000 Patches: 20091217__issue16434.diff.txt uploaded by tilghman (license 14) 20091222__issue16434__1.6.1.diff.txt uploaded by tilghman (license 14) Tested by: rickead2000 ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=237405 By: Digium Subversion (svnbot) 2010-01-04 12:28:29.000-0600 Repository: asterisk Revision: 237406 _U trunk/ U trunk/include/asterisk/channel.h U trunk/main/pbx.c U trunk/res/res_agi.c ------------------------------------------------------------------------ r237406 | tilghman | 2010-01-04 12:28:29 -0600 (Mon, 04 Jan 2010) | 23 lines Merged revisions 237405 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r237405 | tilghman | 2010-01-04 12:19:00 -0600 (Mon, 04 Jan 2010) | 16 lines Add a flag to disable the Background behavior, for AGI users. This is in a section of code that relates to two other issues, namely issue ASTERISK-13159 and issue ASTERISK-13929), one of which was the behavior of Background when called with a context argument that matched the current context. This fix broke FreePBX, however, in a post-Dial situation. Needless to say, this is an extremely difficult collision of several different issues. While the use of an exception flag is ugly, fixing all of the issues linked is rather difficult (although if someone would like to propose a better solution, we're happy to entertain that suggestion). (closes issue ASTERISK-15306) Reported by: rickead2000 Patches: 20091217__issue16434.diff.txt uploaded by tilghman (license 14) 20091222__issue16434__1.6.1.diff.txt uploaded by tilghman (license 14) Tested by: rickead2000 ........ ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=237406 By: Digium Subversion (svnbot) 2010-01-04 12:30:36.000-0600 Repository: asterisk Revision: 237407 _U branches/1.6.0/ U branches/1.6.0/include/asterisk/channel.h U branches/1.6.0/main/pbx.c U branches/1.6.0/res/res_agi.c ------------------------------------------------------------------------ r237407 | tilghman | 2010-01-04 12:30:36 -0600 (Mon, 04 Jan 2010) | 30 lines Merged revisions 237406 via svnmerge from https://origsvn.digium.com/svn/asterisk/trunk ................ r237406 | tilghman | 2010-01-04 12:28:28 -0600 (Mon, 04 Jan 2010) | 23 lines Merged revisions 237405 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r237405 | tilghman | 2010-01-04 12:19:00 -0600 (Mon, 04 Jan 2010) | 16 lines Add a flag to disable the Background behavior, for AGI users. This is in a section of code that relates to two other issues, namely issue ASTERISK-13159 and issue ASTERISK-13929), one of which was the behavior of Background when called with a context argument that matched the current context. This fix broke FreePBX, however, in a post-Dial situation. Needless to say, this is an extremely difficult collision of several different issues. While the use of an exception flag is ugly, fixing all of the issues linked is rather difficult (although if someone would like to propose a better solution, we're happy to entertain that suggestion). (closes issue ASTERISK-15306) Reported by: rickead2000 Patches: 20091217__issue16434.diff.txt uploaded by tilghman (license 14) 20091222__issue16434__1.6.1.diff.txt uploaded by tilghman (license 14) Tested by: rickead2000 ........ ................ ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=237407 By: Digium Subversion (svnbot) 2010-01-04 12:30:45.000-0600 Repository: asterisk Revision: 237408 _U branches/1.6.1/ U branches/1.6.1/include/asterisk/channel.h U branches/1.6.1/main/pbx.c U branches/1.6.1/res/res_agi.c ------------------------------------------------------------------------ r237408 | tilghman | 2010-01-04 12:30:44 -0600 (Mon, 04 Jan 2010) | 30 lines Merged revisions 237406 via svnmerge from https://origsvn.digium.com/svn/asterisk/trunk ................ r237406 | tilghman | 2010-01-04 12:28:28 -0600 (Mon, 04 Jan 2010) | 23 lines Merged revisions 237405 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r237405 | tilghman | 2010-01-04 12:19:00 -0600 (Mon, 04 Jan 2010) | 16 lines Add a flag to disable the Background behavior, for AGI users. This is in a section of code that relates to two other issues, namely issue ASTERISK-13159 and issue ASTERISK-13929), one of which was the behavior of Background when called with a context argument that matched the current context. This fix broke FreePBX, however, in a post-Dial situation. Needless to say, this is an extremely difficult collision of several different issues. While the use of an exception flag is ugly, fixing all of the issues linked is rather difficult (although if someone would like to propose a better solution, we're happy to entertain that suggestion). (closes issue ASTERISK-15306) Reported by: rickead2000 Patches: 20091217__issue16434.diff.txt uploaded by tilghman (license 14) 20091222__issue16434__1.6.1.diff.txt uploaded by tilghman (license 14) Tested by: rickead2000 ........ ................ ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=237408 By: Digium Subversion (svnbot) 2010-01-04 12:30:54.000-0600 Repository: asterisk Revision: 237409 _U branches/1.6.2/ U branches/1.6.2/include/asterisk/channel.h U branches/1.6.2/main/pbx.c U branches/1.6.2/res/res_agi.c ------------------------------------------------------------------------ r237409 | tilghman | 2010-01-04 12:30:53 -0600 (Mon, 04 Jan 2010) | 30 lines Merged revisions 237406 via svnmerge from https://origsvn.digium.com/svn/asterisk/trunk ................ r237406 | tilghman | 2010-01-04 12:28:28 -0600 (Mon, 04 Jan 2010) | 23 lines Merged revisions 237405 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r237405 | tilghman | 2010-01-04 12:19:00 -0600 (Mon, 04 Jan 2010) | 16 lines Add a flag to disable the Background behavior, for AGI users. This is in a section of code that relates to two other issues, namely issue ASTERISK-13159 and issue ASTERISK-13929), one of which was the behavior of Background when called with a context argument that matched the current context. This fix broke FreePBX, however, in a post-Dial situation. Needless to say, this is an extremely difficult collision of several different issues. While the use of an exception flag is ugly, fixing all of the issues linked is rather difficult (although if someone would like to propose a better solution, we're happy to entertain that suggestion). (closes issue ASTERISK-15306) Reported by: rickead2000 Patches: 20091217__issue16434.diff.txt uploaded by tilghman (license 14) 20091222__issue16434__1.6.1.diff.txt uploaded by tilghman (license 14) Tested by: rickead2000 ........ ................ ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=237409 |