[asterisk-bugs] [JIRA] (ASTERISK-27047) res_pjsip user_eq_phone=yes adds user=phone to From: "anonymous" <sip:anonymous at anonymous.invalid>

Richard Mudgett (JIRA) noreply at issues.asterisk.org
Fri Jun 9 11:08:57 CDT 2017


     [ https://issues.asterisk.org/jira/browse/ASTERISK-27047?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Richard Mudgett updated ASTERISK-27047:
---------------------------------------

    Description: 
With pjsip (asterisk 13.14.1) I see the problem that an anonymous from
header gets user=phone appendend to the URI if user_eq_phone=yes is
specified:

On the incoming leg:
{noformat}
From: anonymous <sip:anonymous at anonymous.invalid:5060>;tag=Q5zBj7BMnvI6Fe6O2866fox3ZHmn-smt
{noformat}
Get transformed to
{noformat}
From: "Anonymous" <sip:anonymous at anonymous.invalid;user=phone>;tag=fa3cb748-6af9-485f-8a70-a2b9ad40b13a
{noformat}
on the outgoing leg.

Setting user_eq_phone = no will result in user=phone not being added.
The upstream provide demands user=phone in URIs if the username
resembles a phonenumber, but declines the INVITE if user=phone is
present on an anonymous username.

Looking at the code,res/res_pjsip.c function ast_sip_add_usereqphone is
the only place I see that might add user=phone:

{code}
        int i = 0;
        //.....
        if (pj_strbuf(&sip_uri->user)[0] == '+') {
                i = 1;
        }

        /* Test URI user against allowed characters in AST_DIGIT_ANY */
        for (; i < pj_strlen(&sip_uri->user); i++) {
                if (!strchr(AST_DIGIT_ANYNUM, pj_strbuf(&sip_uri->user)[i])) {
                        break;
                }
        }

        if (i < pj_strlen(&sip_uri->user)) {
                return;
        }

         //add user=phone if we get to the code below
{code}

sip_uri->user should be "anonymous"
AST_DIGIT_ANY is: #define AST_DIGIT_ANYNUM "0123456789"

So in the for loop the first char of sip_uri->user should result in a
NULL from strchr. Leaving i at the value 0, which is smaller than the
length of sip_uri->user. And thus the function should return before
adding the user=phone. 

So why is user=phone being added?

  was:
With pjsip (asterisk 13.14.1) I see the problem that an anonymous from
header gets user=phone appendend to the URI if user_eq_phone=yes is
specified:

On the incoming leg:
From: anonymous <sip:anonymous at anonymous.invalid:5060>;tag=Q5zBj7BMnvI6Fe6O2866fox3ZHmn-smt
Get transformed to
From: "Anonymous" <sip:anonymous at anonymous.invalid;user=phone>;tag=fa3cb748-6af9-485f-8a70-a2b9ad40b13a
on the outgoing leg.

Setting user_eq_phone = no will result in user=phone not being added.
The upstream provide demands user=phone in URIs if the username
resembles a phonenumber, but declines the INVITE if user=phone is
present on an anonymous username.

Looking at the code,res/res_pjsip.c function ast_sip_add_usereqphone is
the only place I see that might add user=phone:

{code}
        int i = 0;
        //.....
        if (pj_strbuf(&sip_uri->user)[0] == '+') {
                i = 1;
        }

        /* Test URI user against allowed characters in AST_DIGIT_ANY */
        for (; i < pj_strlen(&sip_uri->user); i++) {
                if (!strchr(AST_DIGIT_ANYNUM, pj_strbuf(&sip_uri->user)[i])) {
                        break;
                }
        }

        if (i < pj_strlen(&sip_uri->user)) {
                return;
        }

         //add user=phone if we get to the code below
{code}

sip_uri->user should be "anonymous"
AST_DIGIT_ANY is: #define AST_DIGIT_ANYNUM "0123456789"

So in the for loop the first char of sip_uri->user should result in a
NULL from strchr. Leaving i at the value 0, which is smaller than the
length of sip_uri->user. And thus the function should return before
adding the user=phone. 

So why is user=phone being added?


> res_pjsip user_eq_phone=yes adds user=phone to From: "anonymous" <sip:anonymous at anonymous.invalid>
> --------------------------------------------------------------------------------------------------
>
>                 Key: ASTERISK-27047
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-27047
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: Resources/res_pjsip
>    Affects Versions: 13.14.1
>         Environment: Debian 8
>            Reporter: dtryba
>            Severity: Minor
>         Attachments: pjsip.conf.txt, sip.txt, verbose.txt
>
>
> With pjsip (asterisk 13.14.1) I see the problem that an anonymous from
> header gets user=phone appendend to the URI if user_eq_phone=yes is
> specified:
> On the incoming leg:
> {noformat}
> From: anonymous <sip:anonymous at anonymous.invalid:5060>;tag=Q5zBj7BMnvI6Fe6O2866fox3ZHmn-smt
> {noformat}
> Get transformed to
> {noformat}
> From: "Anonymous" <sip:anonymous at anonymous.invalid;user=phone>;tag=fa3cb748-6af9-485f-8a70-a2b9ad40b13a
> {noformat}
> on the outgoing leg.
> Setting user_eq_phone = no will result in user=phone not being added.
> The upstream provide demands user=phone in URIs if the username
> resembles a phonenumber, but declines the INVITE if user=phone is
> present on an anonymous username.
> Looking at the code,res/res_pjsip.c function ast_sip_add_usereqphone is
> the only place I see that might add user=phone:
> {code}
>         int i = 0;
>         //.....
>         if (pj_strbuf(&sip_uri->user)[0] == '+') {
>                 i = 1;
>         }
>         /* Test URI user against allowed characters in AST_DIGIT_ANY */
>         for (; i < pj_strlen(&sip_uri->user); i++) {
>                 if (!strchr(AST_DIGIT_ANYNUM, pj_strbuf(&sip_uri->user)[i])) {
>                         break;
>                 }
>         }
>         if (i < pj_strlen(&sip_uri->user)) {
>                 return;
>         }
>          //add user=phone if we get to the code below
> {code}
> sip_uri->user should be "anonymous"
> AST_DIGIT_ANY is: #define AST_DIGIT_ANYNUM "0123456789"
> So in the for loop the first char of sip_uri->user should result in a
> NULL from strchr. Leaving i at the value 0, which is smaller than the
> length of sip_uri->user. And thus the function should return before
> adding the user=phone. 
> So why is user=phone being added?



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



More information about the asterisk-bugs mailing list