summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2001-02-09 08:10:22 +0000
committerpeter <peter@FreeBSD.org>2001-02-09 08:10:22 +0000
commitb98f0639942f727084b15146c05b972d8b0fe8fa (patch)
treec7c01dd3e14abac9ef767d5fd77a72758902abcf /sys/kern
parentf1140b25d9d3cf13c3b8fc6266500230807e1a2f (diff)
downloadFreeBSD-src-b98f0639942f727084b15146c05b972d8b0fe8fa.zip
FreeBSD-src-b98f0639942f727084b15146c05b972d8b0fe8fa.tar.gz
poll(2) array limits (take 2) - after some input from bde.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/sys_generic.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c
index eb63ee4..91687aa 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))
OpenPOWER on IntegriCloud