mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: Alexey Izbyshev <izbyshev@ispras.ru>
Cc: musl@lists.openwall.com
Subject: Re: [musl] realpath without procfs -- should be ready for inclusion
Date: Tue, 24 Nov 2020 15:17:33 -0500	[thread overview]
Message-ID: <20201124201733.GD534@brightrain.aerifal.cx> (raw)
In-Reply-To: <20201124143555.GC534@brightrain.aerifal.cx>

On Tue, Nov 24, 2020 at 09:35:55AM -0500, Rich Felker wrote:
> On Tue, Nov 24, 2020 at 12:21:36PM +0300, Alexey Izbyshev wrote:
> > On 2020-11-24 09:30, Rich Felker wrote:
> > >I think before this goes upstream we should have a good set of
> > >testcases that can be contributed to libc-test. Do you have ideas for
> > >coverage? Some that come to mind:
> > >
> > Added some more ideas.
> > 
> > [...]
> > - An argument ending with an absolute symlink with the target having
> > length PATH_MAX-1 (valid path)
> > 
> > Hm, the last one doesn't work now. Since p is the position of NUL
> > instead of the size of stack, "if (k==p) goto toolong;" forbids
> > symlinks with the length of the target == PATH_MAX-1.
> 
> This should be fixable just by increasing size of stack to PATH_MAX+1.
> In theory it doesn't need to be null-terminated but then strchrnul
> won't work. memchr would work instead but it's slightly less
> convenient to use.

One thing I noticed while working out test ideas: my very early
observation that we can use the caller's buffer for output is wrong.
The spec allows it to have been clobbered on failure but not on
success; there's nothing allowing write past the resulting string
size.

It's not too bad to have two 4k buffers, but I think we can actually
put them together. PATH_MAX+1 isn't quite enough because, when
expanding a link, we momentatily need space for both the link name and
contents. However PATH_MAX+NAME_MAX+2 should suffice, since at most
a NAME_MAX part is being removed before pushing the link contents onto
the stack. I don't really feel like making this improvement now
though; it's better done as a change later if desired.

Rich

  reply	other threads:[~2020-11-24 20:17 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-22 22:56 Rich Felker
2020-11-23  2:03 ` Alexey Izbyshev
2020-11-23  3:17   ` Érico Nogueira
2020-11-23  3:34     ` Rich Felker
2020-11-23  3:19   ` Rich Felker
2020-11-23 18:56     ` Rich Felker
2020-11-23 20:53       ` Rich Felker
2020-11-24  3:39         ` Alexey Izbyshev
2020-11-24  4:26           ` Rich Felker
2020-11-24  5:13             ` Alexey Izbyshev
2020-11-24  6:30               ` Rich Felker
2020-11-24  9:21                 ` Alexey Izbyshev
2020-11-24 14:35                   ` Rich Felker
2020-11-24 20:17                     ` Rich Felker [this message]
2020-11-25 15:02                   ` Rich Felker
2020-11-25 19:40                     ` Alexey Izbyshev
2020-11-24 20:31             ` Rich Felker
2020-11-25  5:40               ` Alexey Izbyshev
2020-11-25 15:03                 ` Rich Felker
2020-11-24  3:41     ` Alexey Izbyshev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201124201733.GD534@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=izbyshev@ispras.ru \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).