Do not try to fill fd_set with fd>=FD_SETSIZE

This is UB and causes buffer overflow and crash on linux.
This commit is contained in:
Dmitry Kalinkin 2017-07-18 17:51:50 -04:00
parent 72462b4b6e
commit d5e1bffd2a
No known key found for this signature in database
GPG key ID: 5157B3EC8B2CA333

View file

@ -3835,6 +3835,9 @@ void Worker::waitForInput()
int fdMax = 0;
for (auto & i : children) {
for (auto & j : i.fds) {
if (j >= FD_SETSIZE) {
throw BuildError("reached FD_SETSIZE limit");
}
FD_SET(j, &fds);
if (j >= fdMax) fdMax = j + 1;
}