Commit 3541deb0 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

server: Don't overflow if timeout doesn't fit into int range in get_next_timeout.

parent b67bbb73
......@@ -953,16 +953,18 @@ static int get_next_timeout(void)
if ((ptr = list_head( &abs_timeout_list )) != NULL)
{
struct timeout_user *timeout = LIST_ENTRY( ptr, struct timeout_user, entry );
int diff = (timeout->when - current_time + 9999) / 10000;
if (diff < 0) diff = 0;
timeout_t diff = (timeout->when - current_time + 9999) / 10000;
if (diff > INT_MAX) diff = INT_MAX;
else if (diff < 0) diff = 0;
if (ret == -1 || diff < ret) ret = diff;
}
if ((ptr = list_head( &rel_timeout_list )) != NULL)
{
struct timeout_user *timeout = LIST_ENTRY( ptr, struct timeout_user, entry );
int diff = (-timeout->when - monotonic_time + 9999) / 10000;
if (diff < 0) diff = 0;
timeout_t diff = (-timeout->when - monotonic_time + 9999) / 10000;
if (diff > INT_MAX) diff = INT_MAX;
else if (diff < 0) diff = 0;
if (ret == -1 || diff < ret) ret = diff;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment