From d2817e72468bf460c8758f6ee6bdd804cf317f90 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sat, 29 Mar 2025 10:03:21 +0100 Subject: [BOX32] Small changes in pthread_cond_timedwait wrapping to handle malformed timespec --- src/libtools/threads32.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/libtools') diff --git a/src/libtools/threads32.c b/src/libtools/threads32.c index 3f43d8db..9ad288e9 100755 --- a/src/libtools/threads32.c +++ b/src/libtools/threads32.c @@ -592,7 +592,12 @@ EXPORT int my32_pthread_cond_timedwait_old(x64emu_t* emu, pthread_cond_2_0_t* co { pthread_mutex_t* m = getAlignedMutex((pthread_mutex_t*)mutex); pthread_cond_t * c = get_cond_old(cond); - return pthread_cond_timedwait(c, m, (const struct timespec*)abstime); + struct timespec* atime = abstime; + while(atime->tv_nsec>1000000000LL) { + atime->tv_nsec-=1000000000LL; + ++atime->tv_sec; + } + return pthread_cond_timedwait(c, m, atime); } EXPORT int my32_pthread_cond_wait_old(x64emu_t* emu, pthread_cond_2_0_t* cond, void* mutex) { @@ -605,7 +610,12 @@ EXPORT int my32_pthread_cond_timedwait(x64emu_t* emu, void* cond, void* mutex, v { pthread_mutex_t* m = getAlignedMutex((pthread_mutex_t*)mutex); pthread_cond_t * c = get_cond(cond); - return pthread_cond_timedwait(c, m, (const struct timespec*)abstime); + struct timespec* atime = abstime; + while(atime->tv_nsec>1000000000LL) { + atime->tv_nsec-=1000000000LL; + ++atime->tv_sec; + } + return pthread_cond_timedwait(c, m, atime); } EXPORT int my32_pthread_cond_wait(x64emu_t* emu, void* cond, void* mutex) { -- cgit 1.4.1