If we've got a descriptor table that's bigger than an
fd_set, make sure that all descriptors >2 are closed when we start - otherwise we're asking for a dump in FD_SET(). Problem pointed out by: Theo de Raadt <deraadt@cvs.openbsd.org>
This commit is contained in:
parent
72ca96bfa5
commit
e3b4c40068
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=31823
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: main.c,v 1.106 1997/12/03 10:23:50 brian Exp $
|
||||
* $Id: main.c,v 1.107 1997/12/13 02:37:27 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Add commands for traffic summary, version display, etc.
|
||||
@ -362,6 +362,17 @@ main(int argc, char **argv)
|
||||
{
|
||||
FILE *lockfile;
|
||||
char *name, *label;
|
||||
int nfds;
|
||||
|
||||
nfds = getdtablesize();
|
||||
if (nfds >= FD_SETSIZE)
|
||||
/*
|
||||
* If we've got loads of file descriptors, make sure they're all
|
||||
* closed. If they aren't, we may end up with a seg fault when our
|
||||
* `fd_set's get too big when select()ing !
|
||||
*/
|
||||
while (--nfds > 2)
|
||||
close(nfds);
|
||||
|
||||
VarTerm = 0;
|
||||
name = strrchr(argv[0], '/');
|
||||
|
Loading…
Reference in New Issue
Block a user