Author: imp
Date: Thu Dec 28 05:33:59 2017
New Revision: 327271
URL: https://svnweb.freebsd.org/changeset/base/327271

Log:
  Close slave on fork error to prevent pty fd leak.
  
  CID: 978209

Modified:
  head/lib/libutil/pty.c

Modified: head/lib/libutil/pty.c
==============================================================================
--- head/lib/libutil/pty.c      Thu Dec 28 05:33:54 2017        (r327270)
+++ head/lib/libutil/pty.c      Thu Dec 28 05:33:59 2017        (r327271)
@@ -101,12 +101,13 @@ forkpty(int *amaster, char *name, struct termios *term
                return (-1);
        switch (pid = fork()) {
        case -1:
+               (void)close(slave);
                return (-1);
        case 0:
                /*
                 * child
                 */
-               (void) close(master);
+               (void)close(master);
                login_tty(slave);
                return (0);
        }
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to