summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1997-12-17 21:21:47 +0000
committerbrian <brian@FreeBSD.org>1997-12-17 21:21:47 +0000
commitb8bde84af7f83ae81e7154305167a8b3a1cb4a79 (patch)
tree09330806d10ccbbc5fc2ef85b7390a877f984536
parent4f380fde8de0efa16879edc20885396f3a7433e9 (diff)
downloadFreeBSD-src-b8bde84af7f83ae81e7154305167a8b3a1cb4a79.zip
FreeBSD-src-b8bde84af7f83ae81e7154305167a8b3a1cb4a79.tar.gz
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>
-rw-r--r--usr.sbin/ppp/main.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c
index 4d64a69..f3ac831 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.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], '/');
OpenPOWER on IntegriCloud