diff options
author | alfred <alfred@FreeBSD.org> | 1999-08-20 21:06:20 +0000 |
---|---|---|
committer | alfred <alfred@FreeBSD.org> | 1999-08-20 21:06:20 +0000 |
commit | c54627898a4267bd9a7a2bf98a2da7a238186aa0 (patch) | |
tree | bdbeb014da5293cb6c2fe9fef550bfe1861c990c /lib/libpthread | |
parent | 96374c14c32cf0dd12eb4024cf1519b41b798402 (diff) | |
download | FreeBSD-src-c54627898a4267bd9a7a2bf98a2da7a238186aa0.zip FreeBSD-src-c54627898a4267bd9a7a2bf98a2da7a238186aa0.tar.gz |
move sanity check of timeval struct so as not to segfault when passed
a null pointer.
Pointed out by: Thomas Gellekum <tg@ihf.rwth-aachen.de>
Reviewed by: eivind
Diffstat (limited to 'lib/libpthread')
-rw-r--r-- | lib/libpthread/thread/thr_select.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/libpthread/thread/thr_select.c b/lib/libpthread/thread/thr_select.c index 2042fde..2179160 100644 --- a/lib/libpthread/thread/thr_select.c +++ b/lib/libpthread/thread/thr_select.c @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: uthread_select.c,v 1.9 1999/08/05 12:15:21 deischen Exp $ + * $Id: uthread_select.c,v 1.10 1999/08/19 23:06:11 alfred Exp $ */ #include <unistd.h> #include <errno.h> @@ -53,15 +53,15 @@ select(int numfds, fd_set * readfds, fd_set * writefds, int pfd_index, got_one = 0, fd_count = 0; struct pthread_poll_data data; - if (timeout->tv_sec < 0 || - timeout->tv_usec < 0 || timeout->tv_usec >= 1000000) - return (EINVAL); - if (numfds > _thread_dtablesize) { numfds = _thread_dtablesize; } /* Check if a timeout was specified: */ if (timeout) { + if (timeout->tv_sec < 0 || + timeout->tv_usec < 0 || timeout->tv_usec >= 1000000) + return (EINVAL); + /* Convert the timeval to a timespec: */ TIMEVAL_TO_TIMESPEC(timeout, &ts); |