diff options
author | brian <brian@cvs.openbsd.org> | 1997-12-17 21:17:56 +0000 |
---|---|---|
committer | brian <brian@cvs.openbsd.org> | 1997-12-17 21:17:56 +0000 |
commit | 53c89c0f44a7b2725262d684f4486c4fcfd1fb71 (patch) | |
tree | 50bb57bd5b580f3681c4bf8c0ed7fc1aec54c84a /usr.sbin | |
parent | 3e97932d01e5649169d779cf5aeacf5ed4017bbc (diff) |
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>
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ppp/main.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c index 0c4c5b3ebc8..2882267ceca 100644 --- a/usr.sbin/ppp/main.c +++ b/usr.sbin/ppp/main.c @@ -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.3 1997/12/15 22:44:54 brian Exp $ + * $Id: main.c,v 1.4 1997/12/17 21:17:55 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], '/'); |