summaryrefslogtreecommitdiffstats
path: root/lib/libpthread/thread/thr_poll.c
diff options
context:
space:
mode:
authoralfred <alfred@FreeBSD.org>1999-08-19 23:06:11 +0000
committeralfred <alfred@FreeBSD.org>1999-08-19 23:06:11 +0000
commit557b906ef8a8572a4a3828011b21ce414ce2e283 (patch)
tree0ec3230edcd09a8395fca2f7d9285598e2025c07 /lib/libpthread/thread/thr_poll.c
parent0b6fbc2a5b83ef6eb4b1a5f56ab141146e1d09cc (diff)
downloadFreeBSD-src-557b906ef8a8572a4a3828011b21ce414ce2e283.zip
FreeBSD-src-557b906ef8a8572a4a3828011b21ce414ce2e283.tar.gz
Sanity check time structures passed in, return EINVAL like the system
calls do to avoid corrupting the thread library's concept of wakeup time. PR: kern/12141 Reviewed by: deischen, eivind
Diffstat (limited to 'lib/libpthread/thread/thr_poll.c')
-rw-r--r--lib/libpthread/thread/thr_poll.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/libpthread/thread/thr_poll.c b/lib/libpthread/thread/thr_poll.c
index a54d023..2acd725 100644
--- a/lib/libpthread/thread/thr_poll.c
+++ b/lib/libpthread/thread/thr_poll.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id$
+ * $Id: uthread_poll.c,v 1.1 1999/06/20 08:28:36 jb Exp $
*/
#include <unistd.h>
#include <errno.h>
@@ -58,13 +58,16 @@ poll(struct pollfd *fds, unsigned int nfds, int timeout)
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)) {
OpenPOWER on IntegriCloud