From 64ae78cb9d383926ef94c485ba57c001c7a2b3d5 Mon Sep 17 00:00:00 2001 From: Guy Helmer Date: Tue, 23 May 2000 13:46:04 +0000 Subject: [PATCH] Catch and report fdopen failures. --- usr.sbin/cron/cron/do_command.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/usr.sbin/cron/cron/do_command.c b/usr.sbin/cron/cron/do_command.c index e674563c610a..4bac47ebc4dc 100644 --- a/usr.sbin/cron/cron/do_command.c +++ b/usr.sbin/cron/cron/do_command.c @@ -309,6 +309,11 @@ child_process(e, u) register int escaped = FALSE; register int ch; + if (out == NULL) { + warn("fdopen failed in child2"); + _exit(ERROR_EXIT); + } + Debug(DPROC, ("[%d] child2 sending data to grandchild\n", getpid())) /* close the pipe we don't use, since we inherited it and @@ -369,6 +374,11 @@ child_process(e, u) register FILE *in = fdopen(stdout_pipe[READ_PIPE], "r"); register int ch = getc(in); + if (in == NULL) { + warn("fdopen failed in child"); + _exit(ERROR_EXIT); + } + if (ch != EOF) { register FILE *mail; register int bytes = 1;