Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/pppd/pppd die if fd_set overruns.



details:   https://anonhg.NetBSD.org/src/rev/7ad304e6f70b
branches:  trunk
changeset: 535046:7ad304e6f70b
user:      itojun <itojun%NetBSD.org@localhost>
date:      Fri Aug 09 02:43:58 2002 +0000

description:
die if fd_set overruns.

diffstat:

 usr.sbin/pppd/pppd/sys-bsd.c |   8 ++++++--
 usr.sbin/pppd/pppd/tty.c     |  28 ++++++++++++++++++++++------
 2 files changed, 28 insertions(+), 8 deletions(-)

diffs (106 lines):

diff -r 756b24f5edee -r 7ad304e6f70b usr.sbin/pppd/pppd/sys-bsd.c
--- a/usr.sbin/pppd/pppd/sys-bsd.c      Fri Aug 09 02:40:57 2002 +0000
+++ b/usr.sbin/pppd/pppd/sys-bsd.c      Fri Aug 09 02:43:58 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys-bsd.c,v 1.38 2002/07/01 22:19:41 itojun Exp $      */
+/*     $NetBSD: sys-bsd.c,v 1.39 2002/08/09 02:43:58 itojun Exp $      */
 
 /*
  * sys-bsd.c - System-dependent procedures for setting up
@@ -64,7 +64,7 @@
 #if 0
 #define RCSID  "Id: sys-bsd.c,v 1.47 2000/04/13 12:04:23 paulus Exp "
 #else
-__RCSID("$NetBSD: sys-bsd.c,v 1.38 2002/07/01 22:19:41 itojun Exp $");
+__RCSID("$NetBSD: sys-bsd.c,v 1.39 2002/08/09 02:43:58 itojun Exp $");
 #endif
 #endif
 
@@ -978,6 +978,8 @@
 void add_fd(fd)
     int fd;
 {
+    if (fd >= FD_SETSIZE)
+       fatal("descriptor too big");
     FD_SET(fd, &in_fds);
     if (fd > max_in_fd)
        max_in_fd = fd;
@@ -1006,6 +1008,8 @@
     int n;
 
     FD_ZERO(&ready);
+    if (loop_master >= FD_SETSIZE)
+       fatal("descriptor too big");
     FD_SET(loop_master, &ready);
     n = select(loop_master + 1, &ready, NULL, &ready, timo);
     if (n < 0 && errno != EINTR)
diff -r 756b24f5edee -r 7ad304e6f70b usr.sbin/pppd/pppd/tty.c
--- a/usr.sbin/pppd/pppd/tty.c  Fri Aug 09 02:40:57 2002 +0000
+++ b/usr.sbin/pppd/pppd/tty.c  Fri Aug 09 02:43:58 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty.c,v 1.4 2002/08/02 02:52:07 christos Exp $ */
+/*     $NetBSD: tty.c,v 1.5 2002/08/09 02:43:58 itojun Exp $   */
 
 /*
  * tty.c - code for handling serial ports in pppd.
@@ -27,7 +27,7 @@
 #if 0
 #define RCSID  "Id: tty.c,v 1.6 2001/03/12 22:59:01 paulus Exp "
 #else
-__RCSID("$NetBSD: tty.c,v 1.4 2002/08/02 02:52:07 christos Exp $");
+__RCSID("$NetBSD: tty.c,v 1.5 2002/08/09 02:43:58 itojun Exp $");
 #endif
 #endif
 
@@ -1006,17 +1006,29 @@
        if (nibuf != 0) {
            if (ilevel >= max_level)
                top = &tout;
-           else
+           else {
+               if (pty_master >= FD_SETSIZE)
+                   fatal("descriptor too big");
                FD_SET(pty_master, &writey);
-       } else if (stdin_readable)
+           }
+       } else if (stdin_readable) {
+           if (ifd >= FD_SETSIZE)
+               fatal("descriptor too big");
            FD_SET(ifd, &ready);
+       }
        if (nobuf != 0) {
            if (olevel >= max_level)
                top = &tout;
-           else
+           else {
+               if (ofd >= FD_SETSIZE)
+                   fatal("descriptor too big");
                FD_SET(ofd, &writey);
-       } else if (pty_readable)
+           }
+       } else if (pty_readable) {
+           if (pty_master >= FD_SETSIZE)
+               fatal("descriptor too big");
            FD_SET(pty_master, &ready);
+       }
        if (select(nfds, &ready, &writey, NULL, top) < 0) {
            if (errno != EINTR)
                fatal("select");
@@ -1057,6 +1069,8 @@
                    if (!record_write(recordf, 4, NULL, 0, &lasttime))
                        recordf = NULL;
            } else {
+               if (pty_master >= FD_SETSIZE)
+                   fatal("descriptor too big");
                FD_SET(pty_master, &writey);
                if (recordf)
                    if (!record_write(recordf, 2, ibufp, nibuf, &lasttime))
@@ -1084,6 +1098,8 @@
                    if (!record_write(recordf, 3, NULL, 0, &lasttime))
                        recordf = NULL;
            } else {
+               if (ofd >= FD_SETSIZE)
+                   fatal("descriptor too big");
                FD_SET(ofd, &writey);
                if (recordf)
                    if (!record_write(recordf, 1, obufp, nobuf, &lasttime))



Home | Main Index | Thread Index | Old Index