1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-27 06:11:06 +02:00

20591: Stephane Chazelas: use of fchdir in zchdir leaked fd's

This commit is contained in:
Peter Stephenson 2004-11-29 12:09:13 +00:00
parent cebe5f1d10
commit d2c67e5e19
2 changed files with 10 additions and 3 deletions

View file

@ -1,5 +1,8 @@
2004-11-29 Peter Stephenson <pws@csr.com>
* 20591: Stephane Chazelas <Stephane_Chazelas@yahoo.fr>:
use of fchdir to change directory leaked filed descriptors.
* 20592: Src/math.c: $((##)) caused mayhem by passing null
string to getkeystring(). Report error instead.

View file

@ -387,10 +387,14 @@ zchdir(char *dir)
int currdir = -2;
for (;;) {
if (!*dir)
return 0;
if (!chdir(dir))
if (!*dir || !chdir(dir))
{
#ifdef HAVE_FCHDIR
if (currdir >= 0)
close(currdir);
#endif
return 0;
}
if ((errno != ENAMETOOLONG && errno != ENOMEM) ||
strlen(dir) < PATH_MAX)
break;