From owner-cvs-all Thu Aug 19 13:30:36 1999 Delivered-To: cvs-all@freebsd.org Received: from fw.wintelcom.net (ns1.wintelcom.net [209.1.153.20]) by hub.freebsd.org (Postfix) with ESMTP id B6F9E1526A; Thu, 19 Aug 1999 13:30:27 -0700 (PDT) (envelope-from bright@wintelcom.net) Received: from localhost (bright@localhost) by fw.wintelcom.net (8.8.8/8.8.8) with ESMTP id NAA22149; Thu, 19 Aug 1999 13:45:07 GMT (envelope-from bright@wintelcom.net) Date: Thu, 19 Aug 1999 13:45:07 +0000 (GMT) From: Alfred Perlstein To: Daniel Eischen Cc: chris@calldei.com, alfred@FreeBSD.org, cvs-all@FreeBSD.org, cvs-committers@FreeBSD.org, eivind@FreeBSD.org, jb@FreeBSD.org Subject: Re: cvs commit: src/lib/libc_r/uthread uthread_kern.c In-Reply-To: <199908191945.PAA08513@pcnet1.pcnet.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk On Thu, 19 Aug 1999, Daniel Eischen wrote: > > ok, this should be it, does this look right to everyone: > > > > Index: uthread_cond.c > > =================================================================== > > RCS file: /home/ncvs/src/lib/libc_r/uthread/uthread_cond.c,v > > retrieving revision 1.15 > > diff -u -r1.15 uthread_cond.c > > --- uthread_cond.c 1999/06/20 08:28:13 1.15 > > +++ uthread_cond.c 1999/08/19 23:22:31 > > @@ -261,6 +261,10 @@ > > int rval = 0; > > int status; > > > > + if (abstime->tv_sec < 0 || > > + abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) > > + return (EINVAL); > > + > > if (cond == NULL) > > rval = EINVAL; > > You should also check for tv_nsec < 0. uthread_select.c also > needs to validate the timeval passed in a similar fashion. sorry for that half-baked diff, :) this should catch incorrect values for time passed in to the various timeout functions. the person experiancing the bug is following up by adding debug code to verify that the correct values are being passed into his select calls for a timeout. thank you for the time and patience. Index: uthread_cond.c =================================================================== RCS file: /home/ncvs/src/lib/libc_r/uthread/uthread_cond.c,v retrieving revision 1.15 diff -u -r1.15 uthread_cond.c --- uthread_cond.c 1999/06/20 08:28:13 1.15 +++ uthread_cond.c 1999/08/19 23:22:31 @@ -261,6 +261,10 @@ int rval = 0; int status; + if (abstime->tv_sec < 0 || + abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) + return (EINVAL); + if (cond == NULL) rval = EINVAL; Index: uthread_nanosleep.c =================================================================== RCS file: /home/ncvs/src/lib/libc_r/uthread/uthread_nanosleep.c,v retrieving revision 1.7 diff -u -r1.7 uthread_nanosleep.c --- uthread_nanosleep.c 1999/08/05 12:15:18 1.7 +++ uthread_nanosleep.c 1999/08/19 23:57:15 @@ -48,7 +48,8 @@ struct timeval tv; /* Check if the time to sleep is legal: */ - if (time_to_sleep == NULL || time_to_sleep->tv_nsec < 0 || time_to_sleep->tv_nsec > 1000000000) { + if (time_to_sleep == NULL || time_to_sleep->tv_sec < 0 || + time_to_sleep->tv_nsec < 0 || time_to_sleep->tv_nsec > 1000000000) { /* Return an EINVAL error : */ errno = EINVAL; ret = -1; Index: uthread_poll.c =================================================================== RCS file: /home/ncvs/src/lib/libc_r/uthread/uthread_poll.c,v retrieving revision 1.1 diff -u -r1.1 uthread_poll.c --- uthread_poll.c 1999/06/20 08:28:36 1.1 +++ uthread_poll.c 1999/08/20 00:28:23 @@ -58,13 +58,16 @@ if (timeout == INFTIM) { /* Wait for ever: */ _thread_kern_set_timeout(NULL); - } else if (timeout != 0) { + } else if (timeout > 0) { /* Convert the timeout in msec to a timespec: */ ts.tv_sec = timeout / 1000; ts.tv_nsec = (timeout % 1000) * 1000; /* Set the wake up time: */ _thread_kern_set_timeout(&ts); + } else if (timeout < 0) { + /* a timeout less than zero but not == INFTIM is invalid */ + return (EINVAL); } if (((ret = _thread_sys_poll(fds, numfds, 0)) == 0) && (timeout != 0)) { Index: uthread_select.c =================================================================== RCS file: /home/ncvs/src/lib/libc_r/uthread/uthread_select.c,v retrieving revision 1.9 diff -u -r1.9 uthread_select.c --- uthread_select.c 1999/08/05 12:15:21 1.9 +++ uthread_select.c 1999/08/19 23:55:32 @@ -53,6 +53,10 @@ 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; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message