svn commit: r292607 - head/usr.sbin/cron/cron

Pedro F. Giffuni pfg at FreeBSD.org
Tue Dec 22 15:32:46 UTC 2015


Author: pfg
Date: Tue Dec 22 15:32:45 2015
New Revision: 292607
URL: https://svnweb.freebsd.org/changeset/base/292607

Log:
  cron: Check the return value of pipe(2)
  
  Fix inspired by:	OpenBSD (rev 1.56)
  CID:	1009830

Modified:
  head/usr.sbin/cron/cron/do_command.c

Modified: head/usr.sbin/cron/cron/do_command.c
==============================================================================
--- head/usr.sbin/cron/cron/do_command.c	Tue Dec 22 15:30:26 2015	(r292606)
+++ head/usr.sbin/cron/cron/do_command.c	Tue Dec 22 15:32:45 2015	(r292607)
@@ -114,7 +114,7 @@ child_process(e, u)
 		struct pam_conv pamc = {
 			.conv = openpam_nullconv,
 			.appdata_ptr = NULL
-		};
+		}
 
 		Debug(DPROC, ("[%d] checking account with PAM\n", getpid()))
 
@@ -161,8 +161,10 @@ child_process(e, u)
 
 	/* create some pipes to talk to our future child
 	 */
-	pipe(stdin_pipe);	/* child's stdin */
-	pipe(stdout_pipe);	/* child's stdout */
+	if (pipe(stdin_pipe) != 0 || pipe(stdout_pipe) != 0) {
+		log_it("CRON", getpid(), "error", "can't pipe");
+		exit(ERROR_EXIT);
+	}
 
 	/* since we are a forked process, we can diddle the command string
 	 * we were passed -- nobody else is going to use it again, right?


More information about the svn-src-all mailing list