summaryrefslogtreecommitdiff
path: root/lib/libsndio/sio.c
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2012-10-27 11:58:09 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2012-10-27 11:58:09 +0000
commitfabf9fb15f35f1a9e3fa43dc9da7bf3dcd579df3 (patch)
treed488d07f2c1130ed3e44f525e4600392ac8fec5e /lib/libsndio/sio.c
parent3ab4710bb547985a7f553abaa33c96e2f2cb445b (diff)
check that polled fd number is smaller than SIO_MAXNFDS
Diffstat (limited to 'lib/libsndio/sio.c')
-rw-r--r--lib/libsndio/sio.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/libsndio/sio.c b/lib/libsndio/sio.c
index cf7166d774c..c633354e886 100644
--- a/lib/libsndio/sio.c
+++ b/lib/libsndio/sio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sio.c,v 1.10 2012/05/23 19:25:11 ratchov Exp $ */
+/* $OpenBSD: sio.c,v 1.11 2012/10/27 11:58:08 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -207,11 +207,16 @@ sio_psleep(struct sio_hdl *hdl, int event)
{
struct pollfd pfd[SIO_MAXNFDS];
int revents;
- nfds_t nfds;
+ int nfds;
nfds = sio_nfds(hdl);
+ if (nfds > SIO_MAXNFDS) {
+ DPRINTF("sio_psleep: %d: too many descriptors\n", nfds);
+ hdl->eof = 1;
+ return 0;
+ }
for (;;) {
- sio_pollfd(hdl, pfd, event);
+ nfds = sio_pollfd(hdl, pfd, event);
while (poll(pfd, nfds, -1) < 0) {
if (errno == EINTR)
continue;