diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1999-03-22 02:22:16 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1999-03-22 02:22:16 +0000 |
commit | a367537cfe770b41ab17b10c8d364241f8f4d689 (patch) | |
tree | 5adca021685419357130e5c71dc505edfc580fd5 /sys/kern | |
parent | 278a66c97d5a4e5090c5b0865ca3ce05c67a022a (diff) |
in poll(), constrain nfds better, to avoid kvm starvation; alex
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/sys_generic.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index 9e379a48fb6..b590c6ce82f 100644 --- a/sys/kern/sys_generic.c +++ b/sys/kern/sys_generic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_generic.c,v 1.17 1999/02/14 21:11:01 millert Exp $ */ +/* $OpenBSD: sys_generic.c,v 1.18 1999/03/22 02:22:15 deraadt Exp $ */ /* $NetBSD: sys_generic.c,v 1.24 1996/03/29 00:25:32 cgd Exp $ */ /* @@ -807,13 +807,18 @@ sys_poll(p, v, retval) register_t *retval; { struct sys_poll_args *uap = v; - size_t sz = sizeof(struct pollfd) * SCARG(uap, nfds); + size_t sz; struct pollfd *pl; int msec = SCARG(uap, timeout); struct timeval atv; int timo, ncoll, i, s, error, error2; extern int nselcoll, selwait; + /* XXX constrain; This may not match standards */ + if (SCARG(uap, nfds) > p->p_fd->fd_nfiles) + SCARG(uap, nfds) = p->p_fd->fd_nfiles; + sz = sizeof(struct pollfd) * SCARG(uap, nfds); + pl = (struct pollfd *) malloc(sz, M_TEMP, M_WAITOK); if ((error = copyin(SCARG(uap, fds), pl, sz)) != 0) |