<p>Joshua Colp has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/14635">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pjsip: Include timer patch to prevent cancelling timer 0.<br><br>I noticed this while looking at another issue and brought<br>it up with Teluu. It was possible for an uninitialized timer<br>to be cancelled, resulting in the invalid timer id of 0<br>being placed into the timer heap causing issues.<br><br>This change is a backport from the pjproject repository<br>preventing this from happening.<br><br>Change-Id: I1ba318b1f153a6dd7458846396e2867282b428e7<br>---<br>A third-party/pjproject/patches/0020-pjlib_cancel_timer_0.patch<br>1 file changed, 39 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/35/14635/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/third-party/pjproject/patches/0020-pjlib_cancel_timer_0.patch b/third-party/pjproject/patches/0020-pjlib_cancel_timer_0.patch</span><br><span>new file mode 100644</span><br><span>index 0000000..09f72d8</span><br><span>--- /dev/null</span><br><span>+++ b/third-party/pjproject/patches/0020-pjlib_cancel_timer_0.patch</span><br><span>@@ -0,0 +1,39 @@</span><br><span style="color: hsl(120, 100%, 40%);">+commit 40dd48d10911f4ff9b8dfbf16428fbc9acc434ba</span><br><span style="color: hsl(120, 100%, 40%);">+Author: Riza Sulistyo <trengginas@users.noreply.github.com></span><br><span style="color: hsl(120, 100%, 40%);">+Date:   Thu Jul 9 17:47:24 2020 +0700</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    Modify timer_id check on cancel() (#2463)</span><br><span style="color: hsl(120, 100%, 40%);">+    </span><br><span style="color: hsl(120, 100%, 40%);">+    * modify timer_id check on cancel().</span><br><span style="color: hsl(120, 100%, 40%);">+    </span><br><span style="color: hsl(120, 100%, 40%);">+    * modification based on comments.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+diff --git a/pjlib/include/pj/timer.h b/pjlib/include/pj/timer.h</span><br><span style="color: hsl(120, 100%, 40%);">+index b738a6e76..4b76ab65d 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/pjlib/include/pj/timer.h</span><br><span>++++ b/pjlib/include/pj/timer.h</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -120,7 +120,10 @@ typedef struct pj_timer_entry</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+     /** </span><br><span style="color: hsl(120, 100%, 40%);">+      * Internal unique timer ID, which is assigned by the timer heap. </span><br><span style="color: hsl(120, 100%, 40%);">+-     * Application should not touch this ID.</span><br><span style="color: hsl(120, 100%, 40%);">++     * Positive values indicate that the timer entry is running, </span><br><span style="color: hsl(120, 100%, 40%);">++     * while -1 means that it's not. Any other value may indicate that it </span><br><span style="color: hsl(120, 100%, 40%);">++     * hasn't been properly initialised or is in a bad state.</span><br><span style="color: hsl(120, 100%, 40%);">++     * Application should not touch this ID. </span><br><span style="color: hsl(120, 100%, 40%);">+      */</span><br><span style="color: hsl(120, 100%, 40%);">+     pj_timer_id_t _timer_id;</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+diff --git a/pjlib/src/pj/timer.c b/pjlib/src/pj/timer.c</span><br><span style="color: hsl(120, 100%, 40%);">+index 66516fce8..34966c481 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/pjlib/src/pj/timer.c</span><br><span>++++ b/pjlib/src/pj/timer.c</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -535,7 +535,7 @@ static int cancel( pj_timer_heap_t *ht,</span><br><span style="color: hsl(120, 100%, 40%);">+     PJ_CHECK_STACK();</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+     // Check to see if the timer_id is out of range</span><br><span style="color: hsl(120, 100%, 40%);">+-    if (entry->_timer_id < 0 || (pj_size_t)entry->_timer_id > ht->max_size) {</span><br><span style="color: hsl(120, 100%, 40%);">++    if (entry->_timer_id < 1 || (pj_size_t)entry->_timer_id >= ht->max_size) {</span><br><span style="color: hsl(120, 100%, 40%);">+       entry->_timer_id = -1;</span><br><span style="color: hsl(120, 100%, 40%);">+             return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+     }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/14635">change 14635</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/+/14635"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-Change-Id: I1ba318b1f153a6dd7458846396e2867282b428e7 </div>
<div style="display:none"> Gerrit-Change-Number: 14635 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>