mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2025-12-20 06:50:08 +01:00
sysdeps-pthread: Fix timeout overflow adjustment
Fix an off by one error which could produce a tv_nsec value of 1'000'000'000. The valid tv_nsec range is [0, 999,999,999], see https://en.cppreference.com/w/c/chrono/timespec for reference. Passing a timespec with a tv_nsec value of 1'000'000'000 to pthread_cond_timedwait has been observed to cause it to return an error code which in turn makes the DBUS library abort the application when compiled with asserts enabled (by PTHREAD_CHECK). Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/556 Reviewed-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
parent
718476760e
commit
1d73f69afb
1 changed files with 1 additions and 1 deletions
|
|
@ -246,7 +246,7 @@ _dbus_platform_condvar_wait_timeout (DBusCondVar *cond,
|
|||
|
||||
end_time.tv_sec = time_now.tv_sec + timeout_milliseconds / 1000;
|
||||
end_time.tv_nsec = (time_now.tv_usec + (timeout_milliseconds % 1000) * 1000) * 1000;
|
||||
if (end_time.tv_nsec > 1000*1000*1000)
|
||||
if (end_time.tv_nsec >= 1000*1000*1000)
|
||||
{
|
||||
end_time.tv_sec += 1;
|
||||
end_time.tv_nsec -= 1000*1000*1000;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue