diff --git a/src/lib/empthread/pthread.c b/src/lib/empthread/pthread.c index 6339459e..0c0ef5dc 100644 --- a/src/lib/empthread/pthread.c +++ b/src/lib/empthread/pthread.c @@ -29,7 +29,7 @@ * Known contributors to this file: * Sasha Mikheev * Steve McClure, 1998 - * Markus Armbruster, 2005-2010 + * Markus Armbruster, 2005-2011 * Ron Koenderink, 2007-2009 */ @@ -289,6 +289,11 @@ empth_select(int fd, int flags, struct timeval *timeout) empth_t *ctx; int res = 0; + if (CANT_HAPPEN(fd < 0 || fd >= FD_SETSIZE)) { + errno = EBADF; + return -1; + } + ef_make_stale(); pthread_mutex_unlock(&mtx_ctxsw); empth_status("select on %d for %d", fd, flags);