svn commit: r327271 - head/lib/libutil

Warner Losh imp at FreeBSD.org
Thu Dec 28 05:34:02 UTC 2017


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);
 	}


More information about the svn-src-head mailing list