X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;ds=sidebyside;f=pppd%2Ftty.c;h=a7ebe6ff0151055cfab29c706260d51bd3c126f9;hb=e2df1fe10f6940329cbb2fe1e05b18247a005456;hp=803d8ba02edecad13d30d4cc38517d7731b4f56a;hpb=f53a48eb9d74db3c71938e114b7f489c339bc003;p=ppp.git diff --git a/pppd/tty.c b/pppd/tty.c index 803d8ba..a7ebe6f 100644 --- a/pppd/tty.c +++ b/pppd/tty.c @@ -73,7 +73,7 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#define RCSID "$Id: tty.c,v 1.8 2002/12/04 23:03:33 paulus Exp $" +#define RCSID "$Id: tty.c,v 1.10 2003/02/24 11:29:53 fcusack Exp $" #include #include @@ -614,6 +614,11 @@ int connect_tty() if (pipe(ipipe) < 0 || pipe(opipe) < 0) fatal("Couldn't create pipes for record option: %m"); + + /* don't leak these to the ptycommand */ + (void) fcntl(ipipe[0], F_SETFD, FD_CLOEXEC); + (void) fcntl(opipe[1], F_SETFD, FD_CLOEXEC); + ok = device_script(ptycommand, opipe[0], ipipe[1], 1) == 0 && start_charshunt(ipipe[0], opipe[1]); close(ipipe[0]); @@ -992,6 +997,13 @@ charshunt(ifd, ofd, record_file) signal(SIGXFSZ, SIG_DFL); #endif + /* + * Check that the fds won't overrun the fd_sets + */ + if (ifd >= FD_SETSIZE || ofd >= FD_SETSIZE || pty_master >= FD_SETSIZE) + fatal("internal error: file descriptor too large (%d, %d, %d)", + ifd, ofd, pty_master); + /* * Open the record file if required. */