From d22474f5df2457768f069df9d86d0a9bc52a170b Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 17 Jan 1998 23:13:35 +0000 Subject: Make sure we don't pclose() a garbage output sink. svn path=/trunk/; revision=1584 --- driver.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'driver.c') diff --git a/driver.c b/driver.c index 66d4c619..af4956fc 100644 --- a/driver.c +++ b/driver.c @@ -1248,7 +1248,8 @@ int num; /* index of message */ error(0, errno, "writing RFC822 headers"); if (ctl->mda) { - pclose(sinkfp); + if (sinkfp) + pclose(sinkfp); signal(SIGCHLD, sigchld); } return(PS_IOERR); @@ -1342,7 +1343,8 @@ flag forward; /* TRUE to forward */ { if (ctl->mda) { - pclose(sinkfp); + if (sinkfp) + pclose(sinkfp); signal(SIGCHLD, sigchld); } return(PS_SOCKET); @@ -1383,7 +1385,8 @@ flag forward; /* TRUE to forward */ error(0, errno, "writing message text"); if (ctl->mda) { - pclose(sinkfp); + if (sinkfp) + pclose(sinkfp); signal(SIGCHLD, sigchld); } return(PS_IOERR); @@ -1765,6 +1768,9 @@ const struct method *proto; /* protocol method table */ error_build(" "); } + /* later we'll test for this before closing */ + sinkfp = (FILE *)NULL; + /* * Read the message headers and ship them to the * output sink. @@ -1875,7 +1881,10 @@ const struct method *proto; /* protocol method table */ int rc; /* close the delivery pipe, we'll reopen before next message */ - rc = pclose(sinkfp); + if (sinkfp) + rc = pclose(sinkfp); + else + rc = 0; signal(SIGCHLD, sigchld); if (rc) { -- cgit v1.2.3