Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect file descriptor count/limit in select() #149

Open
sjmackenzie opened this issue Apr 29, 2011 · 1 comment
Open

Incorrect file descriptor count/limit in select() #149

sjmackenzie opened this issue Apr 29, 2011 · 1 comment

Comments

@sjmackenzie
Copy link
Member

In platform/emulator/os.cc, the nfds argument to select() is completely wrong - the code erroneously uses the open-files
limit, sysconf(_SC_OPEN_MAX). If that ulimit is set beyond what an fd_set can handle (1024, usually), then disastrous
things will happen very quickly (select() will find bogus bits beyond the fd sets which do not correspond to any open
descriptors and return an error).

In fact, all uses of openMax or osOpenMax() are incorrect and should use FD_SETSIZE instead, because that is how many
descriptors go in an fd_set. This includes the error message that enumerates the descriptors when select() fails.

The attached patch, made against mozart 1.4.0, cures this. Please apply.

@sjmackenzie
Copy link
Member Author

Date: 2009-08-26 20:18
Sender: Mattias Engdegård

Sorry, I should have looked at trunk before filing a bug. It
does indeed look all right in this respect. It still lacks a
range check for indexing into an fd_set, so programs using a
lot of descriptors are likely to corrupt memory, but that is
a separate problem (and nothing I'm concerned with, anyway).

Thanks - this bug can be closed then.
Date: 2009-08-26 19:53
Sender: Raphael Collet

The patch does not match the revision of os.cc on the development
trunk. I Asked Matthias to check the trunk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant