From: Ilya Zakharevich Date: Thu, 26 Feb 1998 02:47:46 +0000 (-0500) Subject: Fix file-descriptor leak when pipes fail via taint checks: X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c2267164204a961273c71c9c103831895724b0b1;p=p5sagit%2Fp5-mst-13.2.git Fix file-descriptor leak when pipes fail via taint checks: Subject: [PATCH] Some patches went through cracks p4raw-id: //depot/perl@593 --- diff --git a/os2/os2.c b/os2/os2.c index fe7f99b..f24c3af 100644 --- a/os2/os2.c +++ b/os2/os2.c @@ -620,8 +620,6 @@ char *mode; PerlIO *res; SV *sv; - if (pipe(p) < 0) - return Nullfp; /* `this' is what we use in the parent, `that' in the child. */ this = (*mode == 'w'); that = !this; @@ -629,6 +627,8 @@ char *mode; taint_env(); taint_proper("Insecure %s%s", "EXEC"); } + if (pipe(p) < 0) + return Nullfp; /* Now we need to spawn the child. */ newfd = dup(*mode == 'r'); /* Preserve std* */ if (p[that] != (*mode == 'r')) { diff --git a/util.c b/util.c index 0dd9443..770aa29 100644 --- a/util.c +++ b/util.c @@ -1855,14 +1855,14 @@ my_popen(char *cmd, char *mode) return my_syspopen(cmd,mode); } #endif - if (PerlProc_pipe(p) < 0) - return Nullfp; This = (*mode == 'w'); that = !This; if (doexec && tainting) { taint_env(); taint_proper("Insecure %s%s", "EXEC"); } + if (PerlProc_pipe(p) < 0) + return Nullfp; while ((pid = (doexec?vfork():fork())) < 0) { if (errno != EAGAIN) { PerlLIO_close(p[This]);