$NetBSD: patch-ae,v 1.1.1.1 2003/04/18 21:45:45 jeremy-c-reed Exp $ --- pppd/tty.c.orig 2002-12-24 00:17:10.000000000 -0800 +++ pppd/tty.c 2002-12-24 00:17:40.000000000 -0800 @@ -744,8 +744,7 @@ if (tty_mode != (mode_t) -1) { if (fchmod(real_ttyfd, tty_mode) != 0) { - /* XXX if devnam is a symlink, this will change the link */ - chmod(devnam, tty_mode); + warn("couldn't restore tty permissions: %m"); } } @@ -996,17 +995,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"); @@ -1047,6 +1058,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)) @@ -1074,6 +1087,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))