summaryrefslogtreecommitdiffstats
path: root/lib/libsndio/sio.c
diff options
context:
space:
mode:
authorratchov <ratchov@openbsd.org>2012-10-27 11:58:08 +0000
committerratchov <ratchov@openbsd.org>2012-10-27 11:58:08 +0000
commit77158b0c1def62b707fabc816458501b5a0840bf (patch)
treebfa649f928c7b2794e6f5421a32432a347292de9 /lib/libsndio/sio.c
parentinclude netinet/in.h to get htons & friends prototypes (diff)
downloadwireguard-openbsd-77158b0c1def62b707fabc816458501b5a0840bf.tar.xz
wireguard-openbsd-77158b0c1def62b707fabc816458501b5a0840bf.zip
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;