<p>George Joseph <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/19692">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span></span><br></pre><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved; Approved for Submit
N A: Looks good to me, but someone else must approve
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip: Fix path usage in case dialing with '@'<br><br>Fix aor lookup on sip path addition. Issue happens in case of dialing<br>with @ and overriding user part of RURI.<br><br>ASTERISK-30100 #close<br>Reported-by: Yury Kirsanov<br><br>Change-Id: I3f2c42a583578c94397b113e32ca3ebf2d600e13<br>---<br>M res/res_pjsip_path.c<br>1 file changed, 23 insertions(+), 69 deletions(-)<br><br></pre>
<pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_pjsip_path.c b/res/res_pjsip_path.c</span><br><span>index 5272a5c..9492ef1 100644</span><br><span>--- a/res/res_pjsip_path.c</span><br><span>+++ b/res/res_pjsip_path.c</span><br><span>@@ -36,71 +36,16 @@</span><br><span> static const pj_str_t PATH_NAME = { "Path", 4 };</span><br><span> static pj_str_t PATH_SUPPORTED_NAME = { "path", 4 };</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-static struct ast_sip_aor *find_aor(struct ast_sip_endpoint *endpoint, pjsip_uri *uri)</span><br><span style="color: hsl(120, 100%, 40%);">+static struct ast_sip_aor *find_aor(struct ast_sip_contact *contact)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- char *configured_aors, *aor_name;</span><br><span style="color: hsl(0, 100%, 40%);">- const pj_str_t *uri_username;</span><br><span style="color: hsl(0, 100%, 40%);">- const pj_str_t *uri_hostname;</span><br><span style="color: hsl(0, 100%, 40%);">- char *domain_name;</span><br><span style="color: hsl(0, 100%, 40%);">- char *username;</span><br><span style="color: hsl(0, 100%, 40%);">- struct ast_str *id = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- if (ast_strlen_zero(endpoint->aors)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!contact) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_strlen_zero(contact->aor)) {</span><br><span> return NULL;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- uri_hostname = ast_sip_pjsip_uri_get_hostname(uri);</span><br><span style="color: hsl(0, 100%, 40%);">- domain_name = ast_alloca(uri_hostname->slen + 1);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_copy_pj_str(domain_name, uri_hostname, uri_hostname->slen + 1);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- uri_username = ast_sip_pjsip_uri_get_username(uri);</span><br><span style="color: hsl(0, 100%, 40%);">- username = ast_alloca(uri_username->slen + 1);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_copy_pj_str(username, uri_username, uri_username->slen + 1);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- /*</span><br><span style="color: hsl(0, 100%, 40%);">- * We may want to match without any user options getting</span><br><span style="color: hsl(0, 100%, 40%);">- * in the way.</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">- AST_SIP_USER_OPTIONS_TRUNCATE_CHECK(username);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- configured_aors = ast_strdupa(endpoint->aors);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- /* Iterate the configured AORs to see if the user or the user+domain match */</span><br><span style="color: hsl(0, 100%, 40%);">- while ((aor_name = ast_strip(strsep(&configured_aors, ",")))) {</span><br><span style="color: hsl(0, 100%, 40%);">- struct ast_sip_domain_alias *alias = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- if (ast_strlen_zero(aor_name)) {</span><br><span style="color: hsl(0, 100%, 40%);">- continue;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- if (!strcmp(username, aor_name)) {</span><br><span style="color: hsl(0, 100%, 40%);">- break;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- if (!id && !(id = ast_str_create(strlen(username) + uri_hostname->slen + 2))) {</span><br><span style="color: hsl(0, 100%, 40%);">- aor_name = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">- break;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- ast_str_set(&id, 0, "%s@", username);</span><br><span style="color: hsl(0, 100%, 40%);">- if ((alias = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "domain_alias", domain_name))) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_str_append(&id, 0, "%s", alias->domain);</span><br><span style="color: hsl(0, 100%, 40%);">- ao2_cleanup(alias);</span><br><span style="color: hsl(0, 100%, 40%);">- } else {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_str_append(&id, 0, "%s", domain_name);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- if (!strcmp(aor_name, ast_str_buffer(id))) {</span><br><span style="color: hsl(0, 100%, 40%);">- break;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- ast_free(id);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- if (ast_strlen_zero(aor_name)) {</span><br><span style="color: hsl(0, 100%, 40%);">- return NULL;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- return ast_sip_location_retrieve_aor(aor_name);</span><br><span style="color: hsl(120, 100%, 40%);">+ return ast_sip_location_retrieve_aor(contact->aor);</span><br><span> }</span><br><span> </span><br><span> /*!</span><br><span>@@ -173,7 +118,7 @@</span><br><span> return;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- aor = find_aor(endpoint, tdata->msg->line.req.uri);</span><br><span style="color: hsl(120, 100%, 40%);">+ aor = find_aor(contact);</span><br><span> if (!aor || !aor->support_path) {</span><br><span> return;</span><br><span> }</span><br><span>@@ -205,7 +150,6 @@</span><br><span> struct pjsip_status_line status = tdata->msg->line.status;</span><br><span> pj_str_t path_dup;</span><br><span> pjsip_generic_string_hdr *path_hdr;</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_contact_hdr *contact_hdr;</span><br><span> RAII_VAR(struct ast_sip_aor *, aor, NULL, ao2_cleanup);</span><br><span> pjsip_cseq_hdr *cseq = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CSEQ, NULL);</span><br><span> const pj_str_t REGISTER_METHOD = {"REGISTER", 8};</span><br><span>@@ -216,12 +160,7 @@</span><br><span> return;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- contact_hdr = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CONTACT, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">- if (!contact_hdr) {</span><br><span style="color: hsl(0, 100%, 40%);">- return;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- aor = find_aor(endpoint, contact_hdr->uri);</span><br><span style="color: hsl(120, 100%, 40%);">+ aor = find_aor(contact);</span><br><span> if (!aor || !aor->support_path || add_supported(tdata)</span><br><span> || path_get_string(tdata->pool, contact, &path_dup)) {</span><br><span> return;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/19692">change 19692</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/19692"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 20 </div>
<div style="display:none"> Gerrit-Change-Id: I3f2c42a583578c94397b113e32ca3ebf2d600e13 </div>
<div style="display:none"> Gerrit-Change-Number: 19692 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Igor Goncharovsky <igor.goncharovsky@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: N A <asterisk@phreaknet.org> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>