From a8657c4b40c74416b1e2cd0ed85d114d0d99cd4b Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 19 Jul 2011 09:26:56 +0000 Subject: 29555: fix problem using open fd beyond max_zsh_fd --- Src/exec.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'Src/exec.c') diff --git a/Src/exec.c b/Src/exec.c index 644a58367..f5b59a36e 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -3008,11 +3008,17 @@ execcmd(Estate state, int input, int output, int how, int last1) if (!checkclobberparam(fn)) fil = -1; else if (fn->fd2 > 9 && - (fn->fd2 > max_zsh_fd || - (fdtable[fn->fd2] != FDT_UNUSED && - fdtable[fn->fd2] != FDT_EXTERNAL) || - fn->fd2 == coprocin || - fn->fd2 == coprocout)) { + /* + * If the requested fd is > max_zsh_fd, + * the shell doesn't know about it. + * Just assume the user knows what they're + * doing. + */ + (fn->fd2 <= max_zsh_fd && + ((fdtable[fn->fd2] != FDT_UNUSED && + fdtable[fn->fd2] != FDT_EXTERNAL) || + fn->fd2 == coprocin || + fn->fd2 == coprocout))) { fil = -1; errno = EBADF; } else { -- cgit 1.4.1