From: Miroslav Lichvar Date: Mon, 8 Jun 2015 12:49:52 +0000 (+0200) Subject: sched: detect timeout overflow in SCH_AddTimeoutByDelay() X-Git-Tag: 2.1-pre1~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea7fae5277c552c182bbadf44bbab3b6d7a5deb0;p=thirdparty%2Fchrony.git 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(). --- diff --git a/sched.c b/sched.c index bee30316..1946745c 100644 --- a/sched.c +++ b/sched.c @@ -330,6 +330,10 @@ SCH_AddTimeoutByDelay(double delay, SCH_TimeoutHandler handler, SCH_ArbitraryArg LCL_ReadRawTime(&now); UTI_AddDoubleToTimeval(&now, delay, &then); + if (UTI_CompareTimevals(&now, &then) > 0) { + LOG_FATAL(LOGF_Scheduler, "Timeout overflow"); + } + return SCH_AddTimeout(&then, handler, arg); }