diff options
author | Peter Wemm <peter@FreeBSD.org> | 2001-02-09 08:10:22 +0000 |
---|---|---|
committer | Peter Wemm <peter@FreeBSD.org> | 2001-02-09 08:10:22 +0000 |
commit | 2bd5ac330fe8c2e433d9457277e365b4cd41a7df (patch) | |
tree | a4178056d3f901b2fb45997f60af3934ed358b94 /sys/kern/sys_generic.c | |
parent | 13ddcc713c99c4b63c4dbf09409fe4220cd61c1a (diff) | |
download | src-2bd5ac330fe8c2e433d9457277e365b4cd41a7df.tar.gz src-2bd5ac330fe8c2e433d9457277e365b4cd41a7df.zip |
poll(2) array limits (take 2) - after some input from bde.
Notes
Notes:
svn path=/head/; revision=72203
Diffstat (limited to 'sys/kern/sys_generic.c')
-rw-r--r-- | sys/kern/sys_generic.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index eb63ee49c821..91687aa649db 100644 --- a/sys/kern/sys_generic.c +++ b/sys/kern/sys_generic.c @@ -858,19 +858,18 @@ poll(p, uap) caddr_t bits; char smallbits[32 * sizeof(struct pollfd)]; struct timeval atv, rtv, ttv; - int s, ncoll, error = 0, timo, lim, nfds; + int s, ncoll, error = 0, timo, nfds; size_t ni; nfds = SCARG(uap, nfds); /* - * This is kinda bogus. We have fd limits, but that doesn't - * map too well to the size of the pfd[] array. Make sure - * we let the process use at least FD_SETSIZE entries. - * The specs say we only have to support OPEN_MAX entries (64). + * This is kinda bogus. We have fd limits, but that is not + * really related to the size of the pollfd array. Make sure + * we let the process use at least FD_SETSIZE entries and at + * least enough for the current limits. We want to be reasonably + * safe, but not overly restrictive. */ - lim = min((int)p->p_rlimit[RLIMIT_NOFILE].rlim_cur, maxfilesperproc); - lim = min(lim, FD_SETSIZE); - if (nfds > lim) + if (nfds > p->p_rlimit[RLIMIT_NOFILE].rlim_cur && nfds > FD_SETSIZE) return (EINVAL); ni = nfds * sizeof(struct pollfd); if (ni > sizeof(smallbits)) |