<p>Kevin Harwell <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/18594">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, approved; Approved for Submit
</div><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 triggered, 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, 9 insertions(+), 4 deletions(-)<br><br></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..98f9169 100644</span><br><span>--- a/res/res_calendar.c</span><br><span>+++ b/res/res_calendar.c</span><br><span>@@ -998,10 +998,15 @@</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(0, 100%, 40%);">- ast_mutex_lock(&refreshlock);</span><br><span style="color: hsl(0, 100%, 40%);">- AST_SCHED_REPLACE(old_event->bs_end_sched, sched, devstate_sched_end, calendar_devstate_change, old_event);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_mutex_unlock(&refreshlock);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_debug(3, "Calendar bs_end event notification scheduled to happen in %ld ms\n", (long) devstate_sched_end);</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_log(LOG_WARNING, "Whoops! Event end notification scheduled in the past: %ld ms\n", (long) devstate_sched_end);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_mutex_lock(&refreshlock);</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_SCHED_REPLACE(old_event->bs_end_sched, sched, devstate_sched_end, calendar_devstate_change, old_event);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_mutex_unlock(&refreshlock);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(3, "Calendar bs_end event notification scheduled to happen in %ld ms\n", (long) devstate_sched_end);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> }</span><br><span> </span><br><span> if (changed) {</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/+/18594">change 18594</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/+/18594"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: Idfb3204d195f350d2575fb4bc72a54a597d6e93c </div>
<div style="display:none"> Gerrit-Change-Number: 18594 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </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: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>