summaryrefslogtreecommitdiff
path: root/vms/vms.c
diff options
context:
space:
mode:
authorCraig A. Berry <craigberry@mac.com>2013-12-08 08:06:58 -0600
committerCraig A. Berry <craigberry@mac.com>2013-12-08 08:06:58 -0600
commit3f80905d826ca575b32dfd055bb589024a4cc76c (patch)
treed3b52f34889248b4439cf38646decc58d7742771 /vms/vms.c
parent9adf376384dd320dfdc45ddce1798bd3f2a704ac (diff)
downloadperl-3f80905d826ca575b32dfd055bb589024a4cc76c.tar.gz
Error check VMS's backticks stdin inheritance.
This is a follow-up to e2d6c6fbf5bb. The use case I've seen is that the translation of SYS$INPUT succeeds but the stat on the resulting file/device fails, possibly due to object protections. So we would be giving the child something it can't open. Add error checking to the logic so in order to set up inheritance of SYS$INPUT: 1.) The translation of SYS$INPUT must succeed. 2.) stat() on the resulting spec must succeed. 3.) The resulting spec must not be a directory.
Diffstat (limited to 'vms/vms.c')
-rw-r--r--vms/vms.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/vms/vms.c b/vms/vms.c
index cb20e3b4a6..d1cb948581 100644
--- a/vms/vms.c
+++ b/vms/vms.c
@@ -4338,9 +4338,10 @@ safe_popen(pTHX_ const char *cmd, const char *in_mode, int *psts)
} else if (*mode == 'n') { /* separate subprocess, no Perl i/o */
/* Let the child inherit standard input, unless it's a directory. */
Stat_t st;
- (void)my_trnlnm("SYS$INPUT", in, 0);
- if (!flex_stat(in, &st) && S_ISDIR(st.st_mode))
- *in = '\0';
+ if (my_trnlnm("SYS$INPUT", in, 0)) {
+ if (flex_stat(in, &st) != 0 || S_ISDIR(st.st_mode))
+ *in = '\0';
+ }
info->out = pipe_mbxtofd_setup(aTHX_ fileno(stdout), out);
if (info->out) {