summaryrefslogtreecommitdiffstats
path: root/lib/libkse
diff options
context:
space:
mode:
authoralfred <alfred@FreeBSD.org>1999-08-20 21:06:20 +0000
committeralfred <alfred@FreeBSD.org>1999-08-20 21:06:20 +0000
commitc54627898a4267bd9a7a2bf98a2da7a238186aa0 (patch)
treebdbeb014da5293cb6c2fe9fef550bfe1861c990c /lib/libkse
parent96374c14c32cf0dd12eb4024cf1519b41b798402 (diff)
downloadFreeBSD-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/libkse')
-rw-r--r--lib/libkse/thread/thr_select.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/libkse/thread/thr_select.c b/lib/libkse/thread/thr_select.c
index 2042fde..2179160 100644
--- a/lib/libkse/thread/thr_select.c
+++ b/lib/libkse/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);
OpenPOWER on IntegriCloud