mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-04 06:15:07 -05:00
sched: detect timeout overflow in SCH_AddTimeoutByDelay()
Abort when the system time gets so close to the end of 32-bit time_t that timeouts added by delay start to overflow. This is an addition to the loop detector in dispatch_timeouts().
This commit is contained in:
4
sched.c
4
sched.c
@@ -330,6 +330,10 @@ SCH_AddTimeoutByDelay(double delay, SCH_TimeoutHandler handler, SCH_ArbitraryArg
|
|||||||
|
|
||||||
LCL_ReadRawTime(&now);
|
LCL_ReadRawTime(&now);
|
||||||
UTI_AddDoubleToTimeval(&now, delay, &then);
|
UTI_AddDoubleToTimeval(&now, delay, &then);
|
||||||
|
if (UTI_CompareTimevals(&now, &then) > 0) {
|
||||||
|
LOG_FATAL(LOGF_Scheduler, "Timeout overflow");
|
||||||
|
}
|
||||||
|
|
||||||
return SCH_AddTimeout(&then, handler, arg);
|
return SCH_AddTimeout(&then, handler, arg);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user