On Thu, 06 Feb 2020 at 12:41:47 -0700, Theo de Raadt wrote:
> > Index: stdlib/posix_pty.c
> > ===================================================================
> > RCS file: /cvs/src/lib/libc/stdlib/posix_pty.c,v
> > retrieving revision 1.3
> > diff -u -p -u -p -r1.3 posix_pty.c
> > --- stdlib/posix_pty.c      25 Jan 2019 00:19:25 -0000      1.3
> > +++ stdlib/posix_pty.c      6 Feb 2020 17:34:15 -0000
> > @@ -36,7 +36,7 @@ posix_openpt(int oflag)
> >  
> >     /* User must specify O_RDWR in oflag. */
> >     if ((oflag & O_ACCMODE) != O_RDWR ||
> > -       (oflag & ~(O_ACCMODE | O_NOCTTY)) != 0) {
> > +       (oflag & ~(O_ACCMODE | O_NOCTTY | O_CLOEXEC)) != 0) {
> >             errno = EINVAL;
> >             return -1;
> >     }
> > @@ -46,7 +46,11 @@ posix_openpt(int oflag)
> >     if (fd != -1) {
> >             if (ioctl(fd, PTMGET, &ptm) != -1) {
> >                     close(ptm.sfd);
> > -                   mfd = ptm.cfd;
> > +                   if ((oflag & O_CLOEXEC) &&
> > +                       fcntl(ptm.cfd, F_SETFD, FD_CLOEXEC) == -1)
> > +                           close(ptm.cfd);
> > +                   else
> > +                           mfd = ptm.cfd;
> >             }
> >             close(fd);
> 
> Only on the child?  The master does not get it?

cfd is the master (controlling), sfd is the child/slave and is 
closed already.

Reply via email to