$NetBSD: patch-bb,v 1.1.1.1 2005/01/02 02:51:43 cube Exp $ --- pppd/tty.c.orig 2004-11-13 13:07:29.000000000 +0100 +++ pppd/tty.c @@ -80,7 +80,6 @@ #include #include #include -#include #include #include #include @@ -216,8 +215,11 @@ option_t tty_options[] = { "Disable hardware flow control", OPT_PRIOSUB | OPT_ALIAS | OPT_NOARG | OPT_VAL(-1) }, { "nocdtrcts", o_int, &crtscts, - "Disable hardware flow control", - OPT_PRIOSUB | OPT_ALIAS | OPT_NOARG | OPT_VAL(-1) }, + "Disable alternate hardware (DTR/CTS) flow control", + OPT_PRIOSUB | OPT_NOARG | OPT_VAL(2) }, + { "-cdtrcts", o_int, &crtscts, + "Disable alternate hardware (DTR/CTS) flow control", + OPT_PRIOSUB | OPT_ALIAS | OPT_NOARG | OPT_VAL(2) }, { "xonxoff", o_special_noarg, (void *)setxonxoff, "Set software (XON/XOFF) flow control", OPT_PRIOSUB }, @@ -840,7 +842,7 @@ finish_tty() #ifndef __linux__ if (tty_mode != (mode_t) -1) { if (fchmod(real_ttyfd, tty_mode) != 0) - error("Couldn't restore tty permissions"); + warn("Couldn't restore tty permissions: %m"); } #endif /* __linux__ */ @@ -1097,17 +1099,29 @@ charshunt(ifd, ofd, record_file) 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"); @@ -1145,6 +1159,8 @@ charshunt(ifd, ofd, record_file) 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)) @@ -1172,6 +1188,8 @@ charshunt(ifd, ofd, record_file) 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))