<p>N A has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/18250">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_calendar: Prevent assertion if event ends in past.<br><br>res_calendar will trigger an assertion currently<br>if the ending time is calculated to be in the past.<br>Unlike the reminder and start times, however, there<br>is currently no check to catch non-positive times<br>and set them to 1. As a result, if we get a negative<br>value by happenstance, this can cause a crash.<br><br>To prevent the assertion from begin trigger, we now<br>use the same logic as the reminder and start events<br>to catch this issue before it can cause a problem.<br><br>ASTERISK-29981 #close<br><br>Change-Id: Idfb3204d195f350d2575fb4bc72a54a597d6e93c<br>---<br>M res/res_calendar.c<br>1 file changed, 6 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/50/18250/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_calendar.c b/res/res_calendar.c</span><br><span>index ba00796..f7dd365 100644</span><br><span>--- a/res/res_calendar.c</span><br><span>+++ b/res/res_calendar.c</span><br><span>@@ -998,6 +998,12 @@</span><br><span>      if (!cmp_event || old_event->end != event->end) {</span><br><span>              changed = 1;</span><br><span>                 devstate_sched_end = (event->end - now.tv_sec) * 1000;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+           if (devstate_sched_end <= 0) { /* if we let this slip by, Asterisk will assert */</span><br><span style="color: hsl(120, 100%, 40%);">+                  ast_debug(1, "Whoops! Event end notification scheduled in the past: %ld ms\n", (long) devstate_sched_end);</span><br><span style="color: hsl(120, 100%, 40%);">+                  devstate_sched_end = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+               }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>          ast_mutex_lock(&refreshlock);</span><br><span>            AST_SCHED_REPLACE(old_event->bs_end_sched, sched, devstate_sched_end, calendar_devstate_change, old_event);</span><br><span>               ast_mutex_unlock(&refreshlock);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/18250">change 18250</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/+/18250"/><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: Idfb3204d195f350d2575fb4bc72a54a597d6e93c </div>
<div style="display:none"> Gerrit-Change-Number: 18250 </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>