Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Dec 2003 19:50:21 -0800 (PST)
From:      "Danny J. Zerkel" <dzerkel@columbus.rr.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/59530: strange bug in /bin/sh
Message-ID:  <200312200350.hBK3oLst007406@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/59530; it has been noted by GNATS.

From: "Danny J. Zerkel" <dzerkel@columbus.rr.com>
To: freebsd-gnats-submit@FreeBSD.org, dima@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@columbus.rr.com



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200312200350.hBK3oLst007406>