summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authordeischen <deischen@FreeBSD.org>1999-08-30 00:02:08 +0000
committerdeischen <deischen@FreeBSD.org>1999-08-30 00:02:08 +0000
commit4bef5403f8a8fe0787101f3f5a555262f3d70b41 (patch)
treea6269f3d35c3d1224512aacadcf0b43891497dc0 /lib
parent48597b2c18bfeb35efb00c8b6071da5e92baf996 (diff)
downloadFreeBSD-src-4bef5403f8a8fe0787101f3f5a555262f3d70b41.zip
FreeBSD-src-4bef5403f8a8fe0787101f3f5a555262f3d70b41.tar.gz
When checking for valid timevals in the wrapped select() and poll()
routines, don't return EINVAL but set errno to EINVAL and return -1. Added a check in pthread_cond_timedwait for a null timespec pointer.
Diffstat (limited to 'lib')
-rw-r--r--lib/libc_r/uthread/uthread_cond.c14
-rw-r--r--lib/libc_r/uthread/uthread_poll.c3
-rw-r--r--lib/libc_r/uthread/uthread_select.c6
-rw-r--r--lib/libkse/thread/thr_cond.c14
-rw-r--r--lib/libkse/thread/thr_poll.c3
-rw-r--r--lib/libkse/thread/thr_select.c6
-rw-r--r--lib/libpthread/thread/thr_cond.c14
-rw-r--r--lib/libpthread/thread/thr_poll.c3
-rw-r--r--lib/libpthread/thread/thr_select.c6
9 files changed, 42 insertions, 27 deletions
diff --git a/lib/libc_r/uthread/uthread_cond.c b/lib/libc_r/uthread/uthread_cond.c
index 079a635..2eb05f9 100644
--- a/lib/libc_r/uthread/uthread_cond.c
+++ b/lib/libc_r/uthread/uthread_cond.c
@@ -261,18 +261,20 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex,
int rval = 0;
int status;
- if (abstime->tv_sec < 0 ||
- abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
- return (EINVAL);
-
- if (cond == NULL)
+ if (cond == NULL || abstime == NULL)
rval = EINVAL;
+ if (abstime->tv_sec < 0 ||
+ abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) {
+ errno = EINVAL;
+ return (-1);
+ }
+
/*
* If the condition variable is statically initialized,
* perform the dynamic initialization:
*/
- else if (*cond != NULL ||
+ if (*cond != NULL ||
(rval = pthread_cond_init(cond,NULL)) == 0) {
/* Lock the condition variable structure: */
_SPINLOCK(&(*cond)->lock);
diff --git a/lib/libc_r/uthread/uthread_poll.c b/lib/libc_r/uthread/uthread_poll.c
index 4967e6c..01916ad 100644
--- a/lib/libc_r/uthread/uthread_poll.c
+++ b/lib/libc_r/uthread/uthread_poll.c
@@ -67,7 +67,8 @@ poll(struct pollfd *fds, unsigned int nfds, int timeout)
_thread_kern_set_timeout(&ts);
} else if (timeout < 0) {
/* a timeout less than zero but not == INFTIM is invalid */
- return (EINVAL);
+ errno = EINVAL;
+ return (-1);
}
if (((ret = _thread_sys_poll(fds, numfds, 0)) == 0) && (timeout != 0)) {
diff --git a/lib/libc_r/uthread/uthread_select.c b/lib/libc_r/uthread/uthread_select.c
index a7ea8cf..9bfae89 100644
--- a/lib/libc_r/uthread/uthread_select.c
+++ b/lib/libc_r/uthread/uthread_select.c
@@ -59,8 +59,10 @@ select(int numfds, fd_set * readfds, fd_set * writefds,
/* Check if a timeout was specified: */
if (timeout) {
if (timeout->tv_sec < 0 ||
- timeout->tv_usec < 0 || timeout->tv_usec >= 1000000)
- return (EINVAL);
+ timeout->tv_usec < 0 || timeout->tv_usec >= 1000000) {
+ errno = EINVAL;
+ return (-1);
+ }
/* Convert the timeval to a timespec: */
TIMEVAL_TO_TIMESPEC(timeout, &ts);
diff --git a/lib/libkse/thread/thr_cond.c b/lib/libkse/thread/thr_cond.c
index 079a635..2eb05f9 100644
--- a/lib/libkse/thread/thr_cond.c
+++ b/lib/libkse/thread/thr_cond.c
@@ -261,18 +261,20 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex,
int rval = 0;
int status;
- if (abstime->tv_sec < 0 ||
- abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
- return (EINVAL);
-
- if (cond == NULL)
+ if (cond == NULL || abstime == NULL)
rval = EINVAL;
+ if (abstime->tv_sec < 0 ||
+ abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) {
+ errno = EINVAL;
+ return (-1);
+ }
+
/*
* If the condition variable is statically initialized,
* perform the dynamic initialization:
*/
- else if (*cond != NULL ||
+ if (*cond != NULL ||
(rval = pthread_cond_init(cond,NULL)) == 0) {
/* Lock the condition variable structure: */
_SPINLOCK(&(*cond)->lock);
diff --git a/lib/libkse/thread/thr_poll.c b/lib/libkse/thread/thr_poll.c
index 4967e6c..01916ad 100644
--- a/lib/libkse/thread/thr_poll.c
+++ b/lib/libkse/thread/thr_poll.c
@@ -67,7 +67,8 @@ poll(struct pollfd *fds, unsigned int nfds, int timeout)
_thread_kern_set_timeout(&ts);
} else if (timeout < 0) {
/* a timeout less than zero but not == INFTIM is invalid */
- return (EINVAL);
+ errno = EINVAL;
+ return (-1);
}
if (((ret = _thread_sys_poll(fds, numfds, 0)) == 0) && (timeout != 0)) {
diff --git a/lib/libkse/thread/thr_select.c b/lib/libkse/thread/thr_select.c
index a7ea8cf..9bfae89 100644
--- a/lib/libkse/thread/thr_select.c
+++ b/lib/libkse/thread/thr_select.c
@@ -59,8 +59,10 @@ select(int numfds, fd_set * readfds, fd_set * writefds,
/* Check if a timeout was specified: */
if (timeout) {
if (timeout->tv_sec < 0 ||
- timeout->tv_usec < 0 || timeout->tv_usec >= 1000000)
- return (EINVAL);
+ timeout->tv_usec < 0 || timeout->tv_usec >= 1000000) {
+ errno = EINVAL;
+ return (-1);
+ }
/* Convert the timeval to a timespec: */
TIMEVAL_TO_TIMESPEC(timeout, &ts);
diff --git a/lib/libpthread/thread/thr_cond.c b/lib/libpthread/thread/thr_cond.c
index 079a635..2eb05f9 100644
--- a/lib/libpthread/thread/thr_cond.c
+++ b/lib/libpthread/thread/thr_cond.c
@@ -261,18 +261,20 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex,
int rval = 0;
int status;
- if (abstime->tv_sec < 0 ||
- abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
- return (EINVAL);
-
- if (cond == NULL)
+ if (cond == NULL || abstime == NULL)
rval = EINVAL;
+ if (abstime->tv_sec < 0 ||
+ abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) {
+ errno = EINVAL;
+ return (-1);
+ }
+
/*
* If the condition variable is statically initialized,
* perform the dynamic initialization:
*/
- else if (*cond != NULL ||
+ if (*cond != NULL ||
(rval = pthread_cond_init(cond,NULL)) == 0) {
/* Lock the condition variable structure: */
_SPINLOCK(&(*cond)->lock);
diff --git a/lib/libpthread/thread/thr_poll.c b/lib/libpthread/thread/thr_poll.c
index 4967e6c..01916ad 100644
--- a/lib/libpthread/thread/thr_poll.c
+++ b/lib/libpthread/thread/thr_poll.c
@@ -67,7 +67,8 @@ poll(struct pollfd *fds, unsigned int nfds, int timeout)
_thread_kern_set_timeout(&ts);
} else if (timeout < 0) {
/* a timeout less than zero but not == INFTIM is invalid */
- return (EINVAL);
+ errno = EINVAL;
+ return (-1);
}
if (((ret = _thread_sys_poll(fds, numfds, 0)) == 0) && (timeout != 0)) {
diff --git a/lib/libpthread/thread/thr_select.c b/lib/libpthread/thread/thr_select.c
index a7ea8cf..9bfae89 100644
--- a/lib/libpthread/thread/thr_select.c
+++ b/lib/libpthread/thread/thr_select.c
@@ -59,8 +59,10 @@ select(int numfds, fd_set * readfds, fd_set * writefds,
/* Check if a timeout was specified: */
if (timeout) {
if (timeout->tv_sec < 0 ||
- timeout->tv_usec < 0 || timeout->tv_usec >= 1000000)
- return (EINVAL);
+ timeout->tv_usec < 0 || timeout->tv_usec >= 1000000) {
+ errno = EINVAL;
+ return (-1);
+ }
/* Convert the timeval to a timespec: */
TIMEVAL_TO_TIMESPEC(timeout, &ts);
OpenPOWER on IntegriCloud