diff options
author | Ilya Zakharevich <ilya@math.berkeley.edu> | 1998-02-25 21:47:46 -0500 |
---|---|---|
committer | Malcolm Beattie <mbeattie@sable.ox.ac.uk> | 1998-02-27 15:26:45 +0000 |
commit | c2267164204a961273c71c9c103831895724b0b1 (patch) | |
tree | e1be7d708a8588e9df821cc20be5a32e5ac3493a | |
parent | 4e2a5f63925503b57176e32249cf6e160bcf9be9 (diff) | |
download | perl-c2267164204a961273c71c9c103831895724b0b1.tar.gz |
Fix file-descriptor leak when pipes fail via taint checks:
Subject: [PATCH] Some patches went through cracks
p4raw-id: //depot/perl@593
-rw-r--r-- | os2/os2.c | 4 | ||||
-rw-r--r-- | util.c | 4 |
2 files changed, 4 insertions, 4 deletions
@@ -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')) { @@ -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]); |