<p>Friendly Automation <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/12957">View Change</a></p><div style="white-space:pre-wrap">Approvals:
George Joseph: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved
Friendly Automation: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_registrar: Validate Contact URI before adding to responses<br><br>If a permanent contact URI associated with an AOR is invalid, we add a<br>Contact header to REGISTER responses with a NULL URI, causing a crash.<br><br>ASTERISK-28463 #close<br><br>Change-Id: Id2b643e58b975bc560aab1c111e6669d54db9102<br>---<br>M res/res_pjsip_registrar.c<br>1 file changed, 11 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_pjsip_registrar.c b/res/res_pjsip_registrar.c</span><br><span>index 2848d5a..a17c06a 100644</span><br><span>--- a/res/res_pjsip_registrar.c</span><br><span>+++ b/res/res_pjsip_registrar.c</span><br><span>@@ -224,14 +224,21 @@</span><br><span> {</span><br><span> struct ast_sip_contact *contact = obj;</span><br><span> pjsip_tx_data *tdata = arg;</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_contact_hdr *hdr = pjsip_contact_hdr_create(tdata->pool);</span><br><span> pj_str_t uri;</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip_uri *parsed;</span><br><span> </span><br><span> pj_strdup2_with_null(tdata->pool, &uri, contact->uri);</span><br><span style="color: hsl(0, 100%, 40%);">- hdr->uri = pjsip_parse_uri(tdata->pool, uri.ptr, uri.slen, PJSIP_PARSE_URI_AS_NAMEADDR);</span><br><span style="color: hsl(0, 100%, 40%);">- hdr->expires = ast_tvdiff_ms(contact->expiration_time, ast_tvnow()) / 1000;</span><br><span style="color: hsl(120, 100%, 40%);">+ parsed = pjsip_parse_uri(tdata->pool, uri.ptr, uri.slen, PJSIP_PARSE_URI_AS_NAMEADDR);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)hdr);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (parsed && (PJSIP_URI_SCHEME_IS_SIP(parsed) || PJSIP_URI_SCHEME_IS_SIPS(parsed))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip_contact_hdr *hdr = pjsip_contact_hdr_create(tdata->pool);</span><br><span style="color: hsl(120, 100%, 40%);">+ hdr->uri = parsed;</span><br><span style="color: hsl(120, 100%, 40%);">+ hdr->expires = ast_tvdiff_ms(contact->expiration_time, ast_tvnow()) / 1000;</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *) hdr);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_WARNING, "Skipping invalid Contact URI \"%.*s\" for AOR %s\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ (int) uri.slen, uri.ptr, contact->aor);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> </span><br><span> return 0;</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/12957">change 12957</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/+/12957"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Id2b643e58b975bc560aab1c111e6669d54db9102 </div>
<div style="display:none"> Gerrit-Change-Number: 12957 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>