From 64dc32039dc1b9e051c1e059a04e6c84b60b1392 Mon Sep 17 00:00:00 2001 From: Nanang Izzuddin Date: Fri, 6 Nov 2015 11:36:06 +0000 Subject: Re #1894: Fixed high socket descriptor check in ioqueue select, it should be against FD_SETSIZE instead of PJ_IOQUEUE_MAX_HANDLES, as PJ_IOQUEUE_MAX_HANDLES can be lower than FD_SETSIZE. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5196 74dad513-b988-da41-8d7b-12977e46ad98 --- pjlib/src/pj/ioqueue_select.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'pjlib/src/pj') diff --git a/pjlib/src/pj/ioqueue_select.c b/pjlib/src/pj/ioqueue_select.c index a0c964b6..8dd01720 100644 --- a/pjlib/src/pj/ioqueue_select.c +++ b/pjlib/src/pj/ioqueue_select.c @@ -338,8 +338,12 @@ PJ_DEF(pj_status_t) pj_ioqueue_register_sock2(pj_pool_t *pool, * avoid potential memory corruption caused by select() when given * an fd that is higher than FD_SETSIZE. */ - if (sizeof(fd_set) < FD_SETSIZE && sock >= PJ_IOQUEUE_MAX_HANDLES) - return PJ_ETOOBIG; + if (sizeof(fd_set) < FD_SETSIZE && sock >= FD_SETSIZE) { + PJ_LOG(4, ("pjlib", "Failed to register socket to ioqueue because " + "socket fd is too big (fd=%d/FD_SETSIZE=%d)", + sock, FD_SETSIZE)); + return PJ_ETOOBIG; + } pj_lock_acquire(ioqueue->lock); -- cgit v1.2.3