From: cheloha Date: Wed, 10 Jan 2024 04:28:43 +0000 (+0000) Subject: pthread_cond_timedwait(3): accept negative absolute timeouts X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=d556a964e02c8a0fe2c0c04dc5814c59e7989dc1;p=openbsd pthread_cond_timedwait(3): accept negative absolute timeouts Negative absolute timeouts are valid inputs. With input from kettenis@. Thread: https://marc.info/?l=openbsd-tech&m=170467558006767&w=2 ok guenther@ --- diff --git a/lib/libc/thread/rthread_cond.c b/lib/libc/thread/rthread_cond.c index 51e9f4f9967..fde4b524fe4 100644 --- a/lib/libc/thread/rthread_cond.c +++ b/lib/libc/thread/rthread_cond.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rthread_cond.c,v 1.5 2019/01/29 17:40:26 mpi Exp $ */ +/* $OpenBSD: rthread_cond.c,v 1.6 2024/01/10 04:28:43 cheloha Exp $ */ /* * Copyright (c) 2017 Martin Pieuchot * Copyright (c) 2012 Philip Guenther @@ -142,8 +142,7 @@ pthread_cond_timedwait(pthread_cond_t *condp, pthread_mutex_t *mutexp, } cond = *condp; - if (abs == NULL || abs->tv_sec < 0 || abs->tv_nsec < 0 || - abs->tv_nsec >= 1000000000) + if (abs == NULL || abs->tv_nsec < 0 || abs->tv_nsec >= 1000000000) return (EINVAL); return (_rthread_cond_timedwait(cond, mutexp, abs)); diff --git a/lib/libc/thread/rthread_sync.c b/lib/libc/thread/rthread_sync.c index 42e1a7ee737..3a9d2d0d647 100644 --- a/lib/libc/thread/rthread_sync.c +++ b/lib/libc/thread/rthread_sync.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rthread_sync.c,v 1.5 2018/04/24 16:28:42 pirofti Exp $ */ +/* $OpenBSD: rthread_sync.c,v 1.6 2024/01/10 04:28:43 cheloha Exp $ */ /* * Copyright (c) 2004,2005 Ted Unangst * Copyright (c) 2012 Philip Guenther @@ -317,7 +317,7 @@ pthread_cond_timedwait(pthread_cond_t *condp, pthread_mutex_t *mutexp, abort(); } - if (abstime == NULL || abstime->tv_sec < 0 || abstime->tv_nsec < 0 || + if (abstime == NULL || abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) return (EINVAL);