sh bug

a.s. mitrohin swp at uni-altai.ru
Fri Mar 26 08:19:51 PST 2004


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


More information about the freebsd-current mailing list