<p>N A has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/17583">View Change</a></p><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 initiating<br>an outgoing call will cause Asterisk to crash. This is because a null field<br>is used, resulting in an offset from null and subsequent memory access<br>violation.<br><br>Since RURI is not guaranteed to exist, we now check if the base pointer is<br>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;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/83/17583/1</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..e9d0c8d 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><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: 1 </div>
<div style="display:none"> Gerrit-Owner: N A <mail@interlinked.x10host.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>