Guard against unusable fd in pthreads' empth_select()
0 <= fd < FD_SETSIZE must hold, or else undefined behavior in FD_SET().
This commit is contained in:
parent
55e689fb31
commit
9be42299b5
1 changed files with 6 additions and 1 deletions
|
@ -29,7 +29,7 @@
|
||||||
* Known contributors to this file:
|
* Known contributors to this file:
|
||||||
* Sasha Mikheev
|
* Sasha Mikheev
|
||||||
* Steve McClure, 1998
|
* Steve McClure, 1998
|
||||||
* Markus Armbruster, 2005-2010
|
* Markus Armbruster, 2005-2011
|
||||||
* Ron Koenderink, 2007-2009
|
* Ron Koenderink, 2007-2009
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -289,6 +289,11 @@ empth_select(int fd, int flags, struct timeval *timeout)
|
||||||
empth_t *ctx;
|
empth_t *ctx;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
|
if (CANT_HAPPEN(fd < 0 || fd >= FD_SETSIZE)) {
|
||||||
|
errno = EBADF;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
ef_make_stale();
|
ef_make_stale();
|
||||||
pthread_mutex_unlock(&mtx_ctxsw);
|
pthread_mutex_unlock(&mtx_ctxsw);
|
||||||
empth_status("select on %d for %d", fd, flags);
|
empth_status("select on %d for %d", fd, flags);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue