Re: sh bug

From: a.s. mitrohin <swp_at_uni-altai.ru>
Date: Fri, 26 Mar 2004 22:19:32 +0600
Denis Antrushin wrote:
>>> builtin cd unable change work directory buf curdir grow anyway.

>> I found this bug as well years back and ended up mentioning it to Jeff 
>> Roberson,
>> I'm not sure how far he got on figuring out what it was.  He did have 
>> some
>> idea's though.  It happens in more than just 'sh', sevral shell's have 
>> this
>> issue so i'm not sure that it's a problem with sh.

> In /usr/src/bin/sh/cd.c (cdlogical(), at line 206):
> 
>         INTOFF;
>         if (updatepwd(badstat ? NULL : dest) < 0 || chdir(curdir) < 0) {
>                 INTON;
>                 return (-1);
>         }
>         INTON;
>         return(0);
> 
> Here, updatepwd() updates curdir and prevdir variables and *after* that
> sh tries to actually change current directory.  And when chdir() fails,
> we don't revert curdir/prevdir changes. :-)

my "quick fix" here...
http://bspu.secna.ru/~swp/freebsd/patches/sh/patch-cd.c

?

/swp
Received on Fri Mar 26 2004 - 07:19:51 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:49 UTC