1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-17 15:01:40 +02:00

27283: failure to dup fd caused mayhem

This commit is contained in:
Peter Stephenson 2009-09-21 20:49:21 +00:00
parent e85349fbf7
commit 997eafdcad
3 changed files with 9 additions and 2 deletions

View file

@ -1,3 +1,8 @@
2009-09-21 Peter Stephenson <p.w.stephenson@ntlworld.com>
* 27283: Src/exec.c, Src/utils.c: failure to dup fd accessed
uninitialised memory and closed the original fd regardless.
2009-09-21 Peter Stephenson <pws@csr.com> 2009-09-21 Peter Stephenson <pws@csr.com>
* users/14411: Src/hashtable.c: only hash stat-able executable * users/14411: Src/hashtable.c: only hash stat-able executable
@ -12197,5 +12202,5 @@
***************************************************** *****************************************************
* This is used by the shell to define $ZSH_PATCHLEVEL * This is used by the shell to define $ZSH_PATCHLEVEL
* $Revision: 1.4784 $ * $Revision: 1.4785 $
***************************************************** *****************************************************

View file

@ -1980,6 +1980,7 @@ addfd(int forked, int *save, struct multio **mfds, int fd1, int fd2, int rflag,
*/ */
if (fdN < 0 && errno != EBADF) { if (fdN < 0 && errno != EBADF) {
zerr("cannot duplicate fd %d: %e", fd1, errno); zerr("cannot duplicate fd %d: %e", fd1, errno);
mfds[fd1] = NULL;
closemnodes(mfds); closemnodes(mfds);
return; return;
} }

View file

@ -1631,6 +1631,7 @@ movefd(int fd)
#else #else
int fe = movefd(dup(fd)); int fe = movefd(dup(fd));
#endif #endif
if (fe != -1)
zclose(fd); zclose(fd);
fd = fe; fd = fe;
} }