[Asterisk-code-review] res_calendar: Prevent assertion if event ends in past. (asterisk[master])
N A
asteriskteam at digium.com
Wed Mar 23 06:08:16 CDT 2022
N A has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/18250 )
Change subject: res_calendar: Prevent assertion if event ends in past.
......................................................................
res_calendar: Prevent assertion if event ends in past.
res_calendar will trigger an assertion currently
if the ending time is calculated to be in the past.
Unlike the reminder and start times, however, there
is currently no check to catch non-positive times
and set them to 1. As a result, if we get a negative
value by happenstance, this can cause a crash.
To prevent the assertion from begin trigger, we now
use the same logic as the reminder and start events
to catch this issue before it can cause a problem.
ASTERISK-29981 #close
Change-Id: Idfb3204d195f350d2575fb4bc72a54a597d6e93c
---
M res/res_calendar.c
1 file changed, 6 insertions(+), 0 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/50/18250/1
diff --git a/res/res_calendar.c b/res/res_calendar.c
index ba00796..f7dd365 100644
--- a/res/res_calendar.c
+++ b/res/res_calendar.c
@@ -998,6 +998,12 @@
if (!cmp_event || old_event->end != event->end) {
changed = 1;
devstate_sched_end = (event->end - now.tv_sec) * 1000;
+
+ if (devstate_sched_end <= 0) { /* if we let this slip by, Asterisk will assert */
+ ast_debug(1, "Whoops! Event end notification scheduled in the past: %ld ms\n", (long) devstate_sched_end);
+ devstate_sched_end = 1;
+ }
+
ast_mutex_lock(&refreshlock);
AST_SCHED_REPLACE(old_event->bs_end_sched, sched, devstate_sched_end, calendar_devstate_change, old_event);
ast_mutex_unlock(&refreshlock);
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/18250
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Idfb3204d195f350d2575fb4bc72a54a597d6e93c
Gerrit-Change-Number: 18250
Gerrit-PatchSet: 1
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220323/393cba39/attachment-0001.html>
More information about the asterisk-code-review
mailing list