[asterisk-bugs] [JIRA] (ASTERISK-29239) Using a = in a parameter for func_conf ODBC command skips it from running

Leandro Dardini (JIRA) noreply at issues.asterisk.org
Sun Jan 10 03:22:16 CST 2021


    [ https://issues.asterisk.org/jira/browse/ASTERISK-29239?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=253332#comment-253332 ] 

Leandro Dardini edited comment on ASTERISK-29239 at 1/10/21 3:20 AM:
---------------------------------------------------------------------

Good idea, but unfortunately the result was the same. Tried with one and several escapes. Tried also using single quote

{noformat}
        9999 => {
             Set(ODBC_QUERY_BUG("one","twoequalthree")="four");
             Set(ODBC_QUERY_BUG("one","two=three")="four");
             Set(ODBC_QUERY_BUG("one","two\=three")="four");
             Set(ODBC_QUERY_BUG("one","two\\=three")="four");
             Set(ODBC_QUERY_BUG("one","two\\\=three")="four");
             Set(ODBC_QUERY_BUG("one","two\\\\=three")="four");
             Set(ODBC_QUERY_BUG('one','two=three')='four');
             Hangup();
        }
{noformat}

{noformat}
[2021-01-10 10:05:50] DEBUG[9509][C-00001494] pbx.c: Launching 'Set'
[2021-01-10 10:05:50] VERBOSE[9509][C-00001494] pbx.c: Executing [9999 at authenticated:1] Set("PJSIP/108-DEVEL-0000001a", "ODBC_QUERY_BUG("one","twoequalthree")="four"") in new stack
2021-01-10 10:05:50] DEBUG[9509][C-00001494] pbx_variables.c: Evaluating 'ARG1' (from 'ARG1}','${ARG2}','${VAL1}')' len 4)
[2021-01-10 10:05:50] DEBUG[9509][C-00001494] pbx_variables.c: Result of 'ARG1' is 'one'
[2021-01-10 10:05:50] DEBUG[9509][C-00001494] pbx_variables.c: Evaluating 'ARG2' (from 'ARG2}','${VAL1}')' len 4)
[2021-01-10 10:05:50] DEBUG[9509][C-00001494] pbx_variables.c: Result of 'ARG2' is 'twoequalthree'
[2021-01-10 10:05:50] DEBUG[9509][C-00001494] pbx_variables.c: Evaluating 'VAL1' (from 'VAL1}')' len 4)
[2021-01-10 10:05:50] DEBUG[9509][C-00001494] pbx_variables.c: Result of 'VAL1' is 'four'
[2021-01-10 10:05:50] DEBUG[9509][C-00001494] pbx.c: Launching 'Set'
[2021-01-10 10:05:50] VERBOSE[9509][C-00001494] pbx.c: Executing [9999 at authenticated:2] Set("PJSIP/108-DEVEL-0000001a", "ODBC_QUERY_BUG("one","two=three")="four"") in new stack
[2021-01-10 10:05:50] DEBUG[9509][C-00001494] pbx.c: Launching 'Set'
[2021-01-10 10:05:50] VERBOSE[9509][C-00001494] pbx.c: Executing [9999 at authenticated:4] Set("PJSIP/108-DEVEL-0000001a", "ODBC_QUERY_BUG("one","two\\=three")="four"") in new stack
[2021-01-10 10:05:50] DEBUG[9509][C-00001494] pbx.c: Launching 'Set'
[2021-01-10 10:05:50] VERBOSE[9509][C-00001494] pbx.c: Executing [9999 at authenticated:5] Set("PJSIP/108-DEVEL-0000001a", "ODBC_QUERY_BUG("one","two\\\=three")="four"") in new stack
[2021-01-10 10:05:50] DEBUG[9509][C-00001494] pbx.c: Launching 'Set'
[2021-01-10 10:05:50] VERBOSE[9509][C-00001494] pbx.c: Executing [9999 at authenticated:6] Set("PJSIP/108-DEVEL-0000001a", "ODBC_QUERY_BUG("one","two\\\\=three")="four"") in new stack
[2021-01-10 10:05:50] DEBUG[9509][C-00001494] pbx.c: Launching 'Set'
[2021-01-10 10:05:50] VERBOSE[9509][C-00001494] pbx.c: Executing [9999 at authenticated:7] Set("PJSIP/108-DEVEL-0000001a", "ODBC_QUERY_BUG('one','two=three')='four'") in new stack
{noformat}

We can see the parser making the mistake in picking up the first = even in the generation of AMI event 

{noformat}
[2021-01-10 10:05:50] DEBUG[9508] manager.c: Examining AMI event:
Event: VarSet
Privilege: dialplan,all
SystemName: srv02
Channel: PJSIP/108-DEVEL-0000001a
ChannelState: 4
ChannelStateDesc: Ring
CallerIDNum: 108
CallerIDName: Ruben P. Terrace
ConnectedLineNum: <unknown>
ConnectedLineName: <unknown>
Language: en
AccountCode: DEVEL
Context: authenticated
Exten: 9999
Priority: 2
Uniqueid: srv02-1610269550.1539
Linkedid: srv02-1610269550.1539
Variable: ODBC_QUERY_BUG("one","two
Value: three\")=\"four\"
{noformat}




was (Author: ldardini):
Good idea, but unfortunately the result was the same. Tried with one and several escapes. Tried also using single quote

{noformat}
[2021-01-10 10:05:50] DEBUG[9509][C-00001494] pbx.c: Launching 'Set'
[2021-01-10 10:05:50] VERBOSE[9509][C-00001494] pbx.c: Executing [9999 at authenticated:1] Set("PJSIP/108-DEVEL-0000001a", "ODBC_QUERY_BUG("one","twoequalthree")="four"") in new stack
2021-01-10 10:05:50] DEBUG[9509][C-00001494] pbx_variables.c: Evaluating 'ARG1' (from 'ARG1}','${ARG2}','${VAL1}')' len 4)
[2021-01-10 10:05:50] DEBUG[9509][C-00001494] pbx_variables.c: Result of 'ARG1' is 'one'
[2021-01-10 10:05:50] DEBUG[9509][C-00001494] pbx_variables.c: Evaluating 'ARG2' (from 'ARG2}','${VAL1}')' len 4)
[2021-01-10 10:05:50] DEBUG[9509][C-00001494] pbx_variables.c: Result of 'ARG2' is 'twoequalthree'
[2021-01-10 10:05:50] DEBUG[9509][C-00001494] pbx_variables.c: Evaluating 'VAL1' (from 'VAL1}')' len 4)
[2021-01-10 10:05:50] DEBUG[9509][C-00001494] pbx_variables.c: Result of 'VAL1' is 'four'
[2021-01-10 10:05:50] DEBUG[9509][C-00001494] pbx.c: Launching 'Set'
[2021-01-10 10:05:50] VERBOSE[9509][C-00001494] pbx.c: Executing [9999 at authenticated:2] Set("PJSIP/108-DEVEL-0000001a", "ODBC_QUERY_BUG("one","two=three")="four"") in new stack
[2021-01-10 10:05:50] DEBUG[9509][C-00001494] pbx.c: Launching 'Set'
[2021-01-10 10:05:50] VERBOSE[9509][C-00001494] pbx.c: Executing [9999 at authenticated:4] Set("PJSIP/108-DEVEL-0000001a", "ODBC_QUERY_BUG("one","two\\=three")="four"") in new stack
[2021-01-10 10:05:50] DEBUG[9509][C-00001494] pbx.c: Launching 'Set'
[2021-01-10 10:05:50] VERBOSE[9509][C-00001494] pbx.c: Executing [9999 at authenticated:5] Set("PJSIP/108-DEVEL-0000001a", "ODBC_QUERY_BUG("one","two\\\=three")="four"") in new stack
[2021-01-10 10:05:50] DEBUG[9509][C-00001494] pbx.c: Launching 'Set'
[2021-01-10 10:05:50] VERBOSE[9509][C-00001494] pbx.c: Executing [9999 at authenticated:6] Set("PJSIP/108-DEVEL-0000001a", "ODBC_QUERY_BUG("one","two\\\\=three")="four"") in new stack
[2021-01-10 10:05:50] DEBUG[9509][C-00001494] pbx.c: Launching 'Set'
[2021-01-10 10:05:50] VERBOSE[9509][C-00001494] pbx.c: Executing [9999 at authenticated:7] Set("PJSIP/108-DEVEL-0000001a", "ODBC_QUERY_BUG('one','two=three')='four'") in new stack
{noformat}

We can see the parser making the mistake in picking up the first = even in the generation of AMI event 

{noformat}
[2021-01-10 10:05:50] DEBUG[9508] manager.c: Examining AMI event:
Event: VarSet
Privilege: dialplan,all
SystemName: srv02
Channel: PJSIP/108-DEVEL-0000001a
ChannelState: 4
ChannelStateDesc: Ring
CallerIDNum: 108
CallerIDName: Ruben P. Terrace
ConnectedLineNum: <unknown>
ConnectedLineName: <unknown>
Language: en
AccountCode: DEVEL
Context: authenticated
Exten: 9999
Priority: 2
Uniqueid: srv02-1610269550.1539
Linkedid: srv02-1610269550.1539
Variable: ODBC_QUERY_BUG("one","two
Value: three\")=\"four\"
{noformat}



> Using a = in a parameter for func_conf ODBC command skips it from running
> -------------------------------------------------------------------------
>
>                 Key: ASTERISK-29239
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-29239
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: Functions/func_odbc
>    Affects Versions: 16.15.0
>         Environment: CentOS 6.x, MySQL 5.7, Asterisk 16.15.0
>            Reporter: Leandro Dardini
>            Assignee: Unassigned
>            Severity: Minor
>         Attachments: full.14
>
>
> If I have a func_odbc function writing in a table and one of the parameters contains a = sign, the command is not executed and no error is reported.
> Let's take a very simple func_odbc entry like:
> {noformat}
> [QUERY_BUG]
> dsn=asteriskcdrdb1,asteriskcdrdb2
> synopsis=Test a query bug
> writesql=insert into cdr(clid,src,dst) values ('${ARG1}','${ARG2}','${VAL1}')
> {noformat}
> And its AEL dialplan usage:
> {noformat}
>         9999 => {
>              Set(ODBC_QUERY_BUG("one","twoequalthree")="four");
>              Set(ODBC_QUERY_BUG("one","two=three")="four");
>              Hangup();
>         }
> {noformat}
> Only the first ODBC_QUERY_BUG command is executed while the second is skipped without any error reported.
> This is the relevant DEBUG. Full DEBUG in attach
> {noformat}
> [2021-01-10 00:50:36] DEBUG[13330][C-00001320] pbx.c: Launching 'Set'
> [2021-01-10 00:50:36] VERBOSE[13330][C-00001320] pbx.c: Executing [9999 at authenticated:1] Set("PJSIP/108-DEVEL-00000017", "ODBC_QUERY_BUG("one","twoequalthree")="four"") in new stack
> [2021-01-10 00:50:36] DEBUG[13330][C-00001320] pbx_variables.c: Evaluating 'ARG1' (from 'ARG1}','${ARG2}','${VAL1}')' len 4)
> [2021-01-10 00:50:36] DEBUG[13330][C-00001320] pbx_variables.c: Result of 'ARG1' is 'one'
> [2021-01-10 00:50:36] DEBUG[13330][C-00001320] pbx_variables.c: Evaluating 'ARG2' (from 'ARG2}','${VAL1}')' len 4)
> [2021-01-10 00:50:36] DEBUG[13330][C-00001320] pbx_variables.c: Result of 'ARG2' is 'twoequalthree'
> [2021-01-10 00:50:36] DEBUG[13330][C-00001320] pbx_variables.c: Evaluating 'VAL1' (from 'VAL1}')' len 4)
> [2021-01-10 00:50:36] DEBUG[13330][C-00001320] pbx_variables.c: Result of 'VAL1' is 'four'
> [2021-01-10 00:50:37] DEBUG[13330][C-00001320] pbx.c: Launching 'Set'
> [2021-01-10 00:50:37] VERBOSE[13330][C-00001320] pbx.c: Executing [9999 at authenticated:2] Set("PJSIP/108-DEVEL-00000017", "ODBC_QUERY_BUG("one","two=three")="four"") in new stack
> [2021-01-10 00:50:37] DEBUG[13330][C-00001320] pbx.c: Launching 'Hangup'
> [2021-01-10 00:50:37] VERBOSE[13330][C-00001320] pbx.c: Executing [9999 at authenticated:3] Hangup("PJSIP/108-DEVEL-00000017", "") in new stack
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list