<p>George Joseph <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/17583">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved; Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">chan_sip: Fix crash when accessing RURI before initiating outgoing call<br><br>Attempting to access ${CHANNEL(ruri)} in a pre-dial handler before<br>initiating an outgoing call will cause Asterisk to crash. This is<br>because a null field is accessed, resulting in an offset from null and<br>subsequent memory access violation.<br><br>Since RURI is not guaranteed to exist, we now check if the base<br>pointer is non-null before calculating an offset.<br><br>ASTERISK-29772<br><br>Change-Id: Icd3b02f07256bbe6615854af5717074087b95a83<br>---<br>M channels/sip/dialplan_functions.c<br>1 file changed, 6 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/channels/sip/dialplan_functions.c b/channels/sip/dialplan_functions.c</span><br><span>index 7c34fc9..74106d1 100644</span><br><span>--- a/channels/sip/dialplan_functions.c</span><br><span>+++ b/channels/sip/dialplan_functions.c</span><br><span>@@ -166,8 +166,12 @@</span><br><span>    } else if (!strcasecmp(args.param, "uri")) {</span><br><span>               ast_copy_string(buf, p->uri, buflen);</span><br><span>     } else if (!strcasecmp(args.param, "ruri")) {</span><br><span style="color: hsl(0, 100%, 40%);">-         char *tmpruri = REQ_OFFSET_TO_STR(&p->initreq, rlpart2);</span><br><span style="color: hsl(0, 100%, 40%);">-         ast_copy_string(buf, tmpruri, buflen);</span><br><span style="color: hsl(120, 100%, 40%);">+                if (p->initreq.data) {</span><br><span style="color: hsl(120, 100%, 40%);">+                     char *tmpruri = REQ_OFFSET_TO_STR(&p->initreq, rlpart2);</span><br><span style="color: hsl(120, 100%, 40%);">+                       ast_copy_string(buf, tmpruri, buflen);</span><br><span style="color: hsl(120, 100%, 40%);">+                } else {</span><br><span style="color: hsl(120, 100%, 40%);">+                      return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+            }</span><br><span>    } else if (!strcasecmp(args.param, "useragent")) {</span><br><span>                 ast_copy_string(buf, p->useragent, buflen);</span><br><span>       } else if (!strcasecmp(args.param, "peername")) {</span><br><span></span><br></pre><div style="white-space:pre-wrap"></div><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/17583">change 17583</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/+/17583"/><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: Icd3b02f07256bbe6615854af5717074087b95a83 </div>
<div style="display:none"> Gerrit-Change-Number: 17583 </div>
<div style="display:none"> Gerrit-PatchSet: 5 </div>
<div style="display:none"> Gerrit-Owner: N A <mail@interlinked.x10host.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@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Sean Bright <sean@seanbright.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>