From fb3ad98f71861c9676c972e00e7c76879ec17e41 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sun, 10 Mar 2013 21:45:04 +0000 Subject: 31141: Tighten NO_CLOBBER restrictions on {fd} syntax to apply only if $fd is exactly an fd and nothing else. --- Src/exec.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Src/exec.c') 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); -- cgit v1.2.3