Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Wrong PWD with chasedots



On Thu, 13 Nov 2014 19:46:20 +0100
Marc Finet <m.dreadlock@xxxxxxxxx> wrote:
> I had some time to investigate and the problem lies in the
> utils.c::xsymlinks() where there is a discrepancy between the content of
> the global variable xbuf and the local value xbuflen:
>  - in the case a symlink is found, xsymlinks() is called,
>  - xbuf is updated but not xbuflen in the calling function
>  - later, when ".." is found, it is trimmed but uses xbuf + xbuflen as
>    starting point, not xbuf + its length. This leads to lose the data
>    set by xsymlinks(), i.e. the name of the sub-directories.
> This wrong behavior has been introduced by commit 3e06aeabd8a9e8384ebaa
> "32294: prevent buffer overflow when scanning very long directory paths
> for symbolic links".
>
> So I have two patches. The first one forces the xbuflen synchronization:

Thanks, I've applied this.

> While reading the xsymlinks() function I think that a (ret >= 0)
> condition should be added in the for() loop to exit early. Or a break
> should be added after setting ret to -1 in the case of error after
> symlink is found. Anyway, it's not homogeneous, but I do not know which
> method is 'cleaner'.

And this.

pws



Messages sorted by: Reverse Date, Date, Thread, Author