server: Don't overflow if timeout doesn't fit into int range in get_next_timeout.
Signed-off-by: Piotr Caban <piotr@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b67bbb732b
commit
3541deb0c3
10
server/fd.c
10
server/fd.c
|
@ -953,16 +953,18 @@ static int get_next_timeout(void)
|
||||||
if ((ptr = list_head( &abs_timeout_list )) != NULL)
|
if ((ptr = list_head( &abs_timeout_list )) != NULL)
|
||||||
{
|
{
|
||||||
struct timeout_user *timeout = LIST_ENTRY( ptr, struct timeout_user, entry );
|
struct timeout_user *timeout = LIST_ENTRY( ptr, struct timeout_user, entry );
|
||||||
int diff = (timeout->when - current_time + 9999) / 10000;
|
timeout_t diff = (timeout->when - current_time + 9999) / 10000;
|
||||||
if (diff < 0) diff = 0;
|
if (diff > INT_MAX) diff = INT_MAX;
|
||||||
|
else if (diff < 0) diff = 0;
|
||||||
if (ret == -1 || diff < ret) ret = diff;
|
if (ret == -1 || diff < ret) ret = diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ptr = list_head( &rel_timeout_list )) != NULL)
|
if ((ptr = list_head( &rel_timeout_list )) != NULL)
|
||||||
{
|
{
|
||||||
struct timeout_user *timeout = LIST_ENTRY( ptr, struct timeout_user, entry );
|
struct timeout_user *timeout = LIST_ENTRY( ptr, struct timeout_user, entry );
|
||||||
int diff = (-timeout->when - monotonic_time + 9999) / 10000;
|
timeout_t diff = (-timeout->when - monotonic_time + 9999) / 10000;
|
||||||
if (diff < 0) diff = 0;
|
if (diff > INT_MAX) diff = INT_MAX;
|
||||||
|
else if (diff < 0) diff = 0;
|
||||||
if (ret == -1 || diff < ret) ret = diff;
|
if (ret == -1 || diff < ret) ret = diff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue