bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: symlink/readlink and trailing slash


From: Eric Blake
Subject: Re: symlink/readlink and trailing slash
Date: Mon, 21 Sep 2009 22:27:39 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Ben Pfaff <blp <at> cs.stanford.edu> writes:

> > +  size_t len = strlen (name);
> > +  if (name[len - 1] == '/')
> > +    {
> 
> If name is "" then the "if" statement will reference name[-1].

Thanks.  I've rebased my working copy to do:

if (len && name[len - 1] == '/')

as well as audited other modules where I've recently added trailing slash 
checks.  Ones like rpl_lstat are already safe - they do the original lstat 
first (which fails with ENOENT) and check slash later; but symlink has to check 
slash first (so that it doesn't create garbage).

> > +  if (symlink ("nowhere", BASE "link1"))
> > +    {
> > +      fputs ("skipping test: symlinks not supported on this filesystem\n",
> > +        stderr);
> 
> Should this print the specific error that was encountered?  I
> suspect that might be handy for debugging.

It's pretty much the same error for multiple tests, but yes, I could add a 
patch to add a strerror on the errno when symlink() and/or link() fail.

-- 
Eric Blake







reply via email to

[Prev in Thread] Current Thread [Next in Thread]