summaryrefslogtreecommitdiff
path: root/Src/exec.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2013-03-10 21:45:04 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2013-03-10 21:45:04 +0000
commitfb3ad98f71861c9676c972e00e7c76879ec17e41 (patch)
tree822327749fcec33888d4aaa90ba43c523c13edeb /Src/exec.c
parent44907223ff14d424dbfcec4871e41053a07a1dc7 (diff)
downloadzsh-fb3ad98f71861c9676c972e00e7c76879ec17e41.tar.gz
zsh-fb3ad98f71861c9676c972e00e7c76879ec17e41.zip
31141: Tighten NO_CLOBBER restrictions on {fd} syntax
to apply only if $fd is exactly an fd and nothing else.
Diffstat (limited to 'Src/exec.c')
-rw-r--r--Src/exec.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 1ecbc3967..fa148756b 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1885,7 +1885,14 @@ checkclobberparam(struct redir *f)
return 0;
}
- if (!isset(CLOBBER) && (fd = (int)getintvalue(v)) &&
+ /*
+ * We can't clobber the value in the parameter if it's
+ * already an opened file descriptor --- that means it's a decimal
+ * integer corresponding to an opened file descriptor,
+ * not merely an expression that evaluates to a file descriptor.
+ */
+ if (!isset(CLOBBER) && (s = getstrvalue(v)) &&
+ (fd = (int)zstrtol(s, &s, 10)) >= 0 && !*s &&
fd <= max_zsh_fd && fdtable[fd] == FDT_EXTERNAL) {
zwarn("can't clobber parameter %s containing file descriptor %d",
f->varid, fd);