Skip to content
Snippets Groups Projects
Commit 493ef500 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

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).
parent 2a9de5d9
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #1075 passed
...@@ -140,6 +140,7 @@ extern "C" time_t DLLCALL getnexteventtime(event_t* event) ...@@ -140,6 +140,7 @@ extern "C" time_t DLLCALL getnexteventtime(event_t* event)
{ {
struct tm tm; struct tm tm;
time_t t = time(NULL); time_t t = time(NULL);
time_t now = t;
if(event->misc & EVENT_DISABLED) if(event->misc & EVENT_DISABLED)
return 0; return 0;
...@@ -160,6 +161,8 @@ extern "C" time_t DLLCALL getnexteventtime(event_t* event) ...@@ -160,6 +161,8 @@ extern "C" time_t DLLCALL getnexteventtime(event_t* event)
t += 24 * 60 * 60; /* already ran today, so add 24hrs */ t += 24 * 60 * 60; /* already ran today, so add 24hrs */
do { 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) if(localtime_r(&t, &tm) == NULL)
return 0; return 0;
if((event->days & (1 << tm.tm_wday)) if((event->days & (1 << tm.tm_wday))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment