Skip to content
Snippets Groups Projects
Commit ad8c3040 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 645c7ba4
No related branches found
No related tags found
No related merge requests found
......@@ -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))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment