From 3b9f82754ff9dad4b5e21aa6dcb84771cbbfb4b6 Mon Sep 17 00:00:00 2001 From: millert Date: Tue, 17 Nov 2015 22:31:44 +0000 Subject: Check pipe(2) return value; noticed by deraadt@ --- usr.sbin/cron/atrun.c | 7 +++++-- usr.sbin/cron/do_command.c | 8 +++++--- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'usr.sbin/cron') diff --git a/usr.sbin/cron/atrun.c b/usr.sbin/cron/atrun.c index 8e29b877130..95f6fbe70ba 100644 --- a/usr.sbin/cron/atrun.c +++ b/usr.sbin/cron/atrun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atrun.c,v 1.41 2015/11/15 23:24:24 millert Exp $ */ +/* $OpenBSD: atrun.c,v 1.42 2015/11/17 22:31:44 millert Exp $ */ /* * Copyright (c) 2002-2003 Todd C. Miller @@ -379,7 +379,10 @@ run_job(atjob *job, char *atfile) /* mark ourselves as different to PS command watchers */ setproctitle("atrun %s", atfile); - pipe(output_pipe); /* child's stdout/stderr */ + if (pipe(output_pipe) != 0) { /* child's stdout/stderr */ + syslog(LOG_ERR, "(CRON) PIPE (%m)"); + _exit(EXIT_FAILURE); + } /* Fork again, child will run the job, parent will catch output. */ switch ((pid = fork())) { diff --git a/usr.sbin/cron/do_command.c b/usr.sbin/cron/do_command.c index 1d5a0158c8e..be9050b7c5a 100644 --- a/usr.sbin/cron/do_command.c +++ b/usr.sbin/cron/do_command.c @@ -1,4 +1,4 @@ -/* $OpenBSD: do_command.c,v 1.55 2015/11/15 23:24:24 millert Exp $ */ +/* $OpenBSD: do_command.c,v 1.56 2015/11/17 22:31:44 millert Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -99,8 +99,10 @@ child_process(entry *e, user *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) { + syslog(LOG_ERR, "(CRON) PIPE (%m)"); + _exit(EXIT_FAILURE); + } /* since we are a forked process, we can diddle the command string * we were passed -- nobody else is going to use it again, right? -- cgit v1.2.3-59-g8ed1b