mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-29 19:00:57 +02:00
20591: Stephane Chazelas: use of fchdir in zchdir leaked fd's
This commit is contained in:
parent
cebe5f1d10
commit
d2c67e5e19
2 changed files with 10 additions and 3 deletions
|
@ -1,5 +1,8 @@
|
||||||
2004-11-29 Peter Stephenson <pws@csr.com>
|
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
|
* 20592: Src/math.c: $((##)) caused mayhem by passing null
|
||||||
string to getkeystring(). Report error instead.
|
string to getkeystring(). Report error instead.
|
||||||
|
|
||||||
|
|
10
Src/compat.c
10
Src/compat.c
|
@ -387,10 +387,14 @@ zchdir(char *dir)
|
||||||
int currdir = -2;
|
int currdir = -2;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (!*dir)
|
if (!*dir || !chdir(dir))
|
||||||
return 0;
|
{
|
||||||
if (!chdir(dir))
|
#ifdef HAVE_FCHDIR
|
||||||
|
if (currdir >= 0)
|
||||||
|
close(currdir);
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
if ((errno != ENAMETOOLONG && errno != ENOMEM) ||
|
if ((errno != ENAMETOOLONG && errno != ENOMEM) ||
|
||||||
strlen(dir) < PATH_MAX)
|
strlen(dir) < PATH_MAX)
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue