summaryrefslogtreecommitdiffstats
path: root/usr.sbin/cron
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2015-11-17 22:31:44 +0000
committermillert <millert@openbsd.org>2015-11-17 22:31:44 +0000
commit3b9f82754ff9dad4b5e21aa6dcb84771cbbfb4b6 (patch)
treea1299e92401a48740406abe534cee43c79172c6b /usr.sbin/cron
parentCheck for setgid() failure before executing editor and warn if (diff)
downloadwireguard-openbsd-3b9f82754ff9dad4b5e21aa6dcb84771cbbfb4b6.tar.xz
wireguard-openbsd-3b9f82754ff9dad4b5e21aa6dcb84771cbbfb4b6.zip
Check pipe(2) return value; noticed by deraadt@
Diffstat (limited to 'usr.sbin/cron')
-rw-r--r--usr.sbin/cron/atrun.c7
-rw-r--r--usr.sbin/cron/do_command.c8
2 files changed, 10 insertions, 5 deletions
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 <Todd.Miller@courtesan.com>
@@ -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?