bin/59530: strange bug in /bin/sh
Danny J. Zerkel
dzerkel at columbus.rr.com
Fri Dec 19 19:54:16 PST 2003
The following reply was made to PR bin/59530; it has been noted by GNATS.
From: "Danny J. Zerkel" <dzerkel at columbus.rr.com>
To: freebsd-gnats-submit at FreeBSD.org, dima at KOT.SPb.Ru
Cc:
Subject: Re: bin/59530: strange bug in /bin/sh
Date: Fri, 19 Dec 2003 22:45:38 -0500
Unfortunately, updatepwd() is what changes curdir to make the
chdir(curdir) attempt to go to the new directory. Doing the chdir()
first, means don't go anywhere, just update where we think we are.
I think the real problem is that the chdir() failure fall back is
cdphysical(), which if the chdir() fails MUST do updatepwd(NULL).
So this patch appears to work correctly:
*** cd.c.orig Fri Dec 19 22:01:40 2003
--- cd.c Fri Dec 19 22:36:33 2003
***************
*** 217,223 ****
{
INTOFF;
! if (chdir(dest) < 0 || updatepwd(NULL) < 0) {
INTON;
return (-1);
}
--- 217,228 ----
{
INTOFF;
! if (chdir(dest) < 0) {
! updatepwd(NULL);
! INTON;
! return (-1);
! }
! if (updatepwd(NULL) < 0) {
INTON;
return (-1);
}
Danny J. Zerkel -- dzerkel at columbus.rr.com
More information about the freebsd-bugs
mailing list