Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201125150357.GH534@brightrain.aerifal.cx>
Date: Wed, 25 Nov 2020 10:03:58 -0500
From: Rich Felker <dalias@...c.org>
To: Alexey Izbyshev <izbyshev@...ras.ru>
Cc: musl@...ts.openwall.com
Subject: Re: realpath without procfs -- should be ready for inclusion

On Wed, Nov 25, 2020 at 08:40:02AM +0300, Alexey Izbyshev wrote:
> I don't see why the size of stack has to be PATH_MAX+1 though. To
> address the issue with symlink targets of PATH_MAX-1 length, it
> seems sufficient to just do the following:
> 
> -               ssize_t k = readlink(output, stack, p);
> -               if (k==p) goto toolong;
> +               ssize_t k = readlink(output, stack, p+1);
> +               if (k==p+1) goto toolong;
> 
> Since p is never past the end of the stack, there is no harm in
> allowing k == p.

Indeed. I think I was concerned about it clobbering the first byte of
the live part of the stack, but on error the stack is discarded
anyway, so that seems to be a non-issue.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.