Summary: | ASTERISK-27047: res_pjsip: user=phone added to Anonymous caller-id when it shouldn't be. | ||
Reporter: | dtryba (dtryba) | Labels: | patch pjsip |
Date Opened: | 2017-06-09 10:18:43 | Date Closed: | 2017-10-12 12:22:50 |
Priority: | Minor | Regression? | |
Status: | Closed/Complete | Components: | Resources/res_pjsip |
Versions: | 13.14.1 | Frequency of Occurrence | Constant |
Related Issues: | |||
Environment: | Debian 8 | Attachments: | ( 0) ASTERISK-27047.diff ( 1) pjsip.conf.txt ( 2) sip.txt ( 3) verbose.txt |
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@anonymous.invalid:5060>;tag=Q5zBj7BMnvI6Fe6O2866fox3ZHmn-smt {noformat} Get transformed to {noformat} From: "Anonymous" <sip:anonymous@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? | ||
Comments: | By: Asterisk Team (asteriskteam) 2017-06-09 10:18:44.659-0500 Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution. A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report. Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process]. By: dtryba (dtryba) 2017-06-09 10:38:28.371-0500 BTW I'm using my patch from ASTERISK-26988 to prevent double user=phone. Should have no impact on this bug. By: dtryba (dtryba) 2017-06-12 09:27:16.916-0500 Joshua already hinted at a session problem. Looking at the code the mangling to Anonymous is done after adding user=phone. Diff moves ast_sip_add_usereqphone to end of function and add a call to the saved version (which is used in PAI construction). With patch the INVITEs and subsequent messages are correct for both anonymous and telephonenumber URIs. By: Friendly Automation (friendly-automation) 2017-10-12 12:22:51.578-0500 Change 6670 merged by Jenkins2: res_pjsip_session: Prevent user=phone being added to anonimized URIs. [https://gerrit.asterisk.org/6670|https://gerrit.asterisk.org/6670] By: Friendly Automation (friendly-automation) 2017-10-12 12:39:46.076-0500 Change 6717 merged by Joshua Colp: res_pjsip_session: Prevent user=phone being added to anonimized URIs. [https://gerrit.asterisk.org/6717|https://gerrit.asterisk.org/6717] By: Friendly Automation (friendly-automation) 2017-10-12 12:40:34.627-0500 Change 6718 merged by Jenkins2: res_pjsip_session: Prevent user=phone being added to anonimized URIs. [https://gerrit.asterisk.org/6718|https://gerrit.asterisk.org/6718] By: Friendly Automation (friendly-automation) 2017-10-12 12:51:43.468-0500 Change 6719 merged by Jenkins2: res_pjsip_session: Prevent user=phone being added to anonimized URIs. [https://gerrit.asterisk.org/6719|https://gerrit.asterisk.org/6719] |