Mail Archives: djgpp/1999/12/09/20:12:27
I think there is a bug in ./src/libc/compat/time/select.c. The code
assumes that select() is always called with a bitset equal to the size
of 'fd_set'. E.g.
fd_set fd_read;
FD_ZERO (&fd_read);
int num = select (10, &fd_read, NULL, NULL, NULL);
But I've seen code that supports bitset of arbitrary size (infact
from 1 to unlimited size). Here the size of 'read' bitset is just
large enough to hold the 'fds' of interest. Which normally is less
than 256 fds (bits). And with correct typecast of an IN/OUT parameter
this is no problem.
select.c:
/* Exit if we found what we were waiting for. */
if (ready > 0)
{
if (readfds)
*readfds = oread;
^^
This may overwrite users bitset in 'readfds'. Similarily for
'writefds' and 'exceptfds'.
Solution would be to loop and set or clear maximum 'nfds' bits.
Gisle V.
- Raw text -