mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-16 18:47:32 -05:00
Fix a potential time-wraparound issue in pinger.c.
A compiler warning drew my attention to the fact that 'next' in pinger_schedule() was an int, not the unsigned long it should have been. And looking at the code that handles it, it was also taking no care with integer wraparound when checking whether an existing scheduled ping should be moved forward. So now I do something a bit more robust, by remembering what time it _was_ when we set pinger->next, and checking if the new time value falls in the interval between those two times.
This commit is contained in:
11
timing.c
11
timing.c
@ -148,6 +148,17 @@ unsigned long schedule_timer(int ticks, timer_fn_t fn, void *ctx)
|
||||
return when;
|
||||
}
|
||||
|
||||
unsigned long timing_last_clock(void)
|
||||
{
|
||||
/*
|
||||
* Return the last value we stored in 'now'. In particular,
|
||||
* calling this just after schedule_timer returns the value of
|
||||
* 'now' that was used to decide when the timer you just set would
|
||||
* go off.
|
||||
*/
|
||||
return now;
|
||||
}
|
||||
|
||||
/*
|
||||
* Call to run any timers whose time has reached the present.
|
||||
* Returns the time (in ticks) expected until the next timer after
|
||||
|
Reference in New Issue
Block a user