Bounds check the argument to FD_SET
Failing to check the FD_SET argument against FD_SETSIZE causes undefined behaviour (segfaults, for example).
This commit is contained in:
parent
27a3964ff7
commit
0716cb868e
1 changed files with 1 additions and 0 deletions
|
@ -49,6 +49,7 @@ int socket_waitfd(p_socket ps, int sw, p_timeout tm) {
|
|||
fd_set rfds, wfds, *rp, *wp;
|
||||
struct timeval tv, *tp;
|
||||
double t;
|
||||
if (*ps >= FD_SETSIZE) return EINVAL;
|
||||
if (timeout_iszero(tm)) return IO_TIMEOUT; /* optimize timeout == 0 case */
|
||||
do {
|
||||
/* must set bits within loop, because select may have modifed them */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue