From ad8c3040c10eb82cc8318648c74d2bb68e62f584 Mon Sep 17 00:00:00 2001 From: Rob Swindell <rob@synchro.net> Date: Mon, 28 Dec 2020 20:31:35 -0800 Subject: [PATCH] More infinite/long event next-run-time brute force search paranoia Don't search more than 1500 days in the future for a next-run date match. This handles erroneous or just bizarre timed event configurations such as February-29 (once ever leap year) or April-31 (never). --- src/sbbs3/data.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sbbs3/data.cpp b/src/sbbs3/data.cpp index f233f4f111..cbc899fb12 100644 --- a/src/sbbs3/data.cpp +++ b/src/sbbs3/data.cpp @@ -140,6 +140,7 @@ extern "C" time_t DLLCALL getnexteventtime(event_t* event) { struct tm tm; time_t t = time(NULL); + time_t now = t; if(event->misc & EVENT_DISABLED) return 0; @@ -160,6 +161,8 @@ extern "C" time_t DLLCALL getnexteventtime(event_t* event) t += 24 * 60 * 60; /* already ran today, so add 24hrs */ do { + if(t > now + (1500 * 24 * 60 * 60)) /* Handle crazy configs, e.g. Feb-29, Apr-31 */ + return 0; if(localtime_r(&t, &tm) == NULL) return 0; if((event->days & (1 << tm.tm_wday)) -- GitLab