1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-09 23:23:14 +02:00

- Make the accept code check if the fd is within bounds instead of relying

on OpenFiles to be correct. This fixes a crash when f.e. 3rd party modules
  have files open but don't increase OpenFiles. Might also fix a curl crash,
  though nobody ever reported one.
This commit is contained in:
Bram Matthys
2012-02-26 10:09:25 +01:00
parent 2e2eea8146
commit c46024fa2d
2 changed files with 16 additions and 1 deletions
+4
View File
@@ -2361,3 +2361,7 @@
- Get rid of networks/ directory, and all references to it. Suggested by
katsklaw and others (#4056).
- Added doc/example.es.conf, translated by Severus_Snape.
- Make the accept code check if the fd is within bounds instead of relying
on OpenFiles to be correct. This fixes a crash when f.e. 3rd party modules
have files open but don't increase OpenFiles. Might also fix a curl crash,
though nobody ever reported one.
+12 -1
View File
@@ -1775,7 +1775,18 @@ int read_message(time_t delay, fdlist *listp)
break;
}
ircstp->is_ac++;
if (++OpenFiles >= MAXCLIENTS)
/* We now check:
* 1) The number of open files, which is the limit imposed by the
* user during ./Config (MAXCONNECTIONS minus a few).
* 2) If the fd number exceeds FD_SETSIZE, which is not
* permitted as otherwise FD_SET() and FD_CLR() will fail
* in read_message()
* Note that the value of FD_SETSIZE may be (much) higher than
* MAXCLIENTS/MAXCONNECTIONS. They are not necessarily the same!
* Check #2 can be removed if poll() is used.
* FIXME: Figure out why I need a FD_SETSIZE-4 here? still have crashes with -1...
*/
if ((++OpenFiles >= MAXCLIENTS) || (fd > FD_SETSIZE-4))
{
ircstp->is_ref++;
if (last_allinuse < TStime() - 15)