On Thu, Jun 30, 2005 at 12:37:26PM -0700, Glenn Linderman wrote:
> >Multiple slashes are simply reduced to a single slash.  If a program is 
> >interpreting /stuff//more/ as /more its busted.  I'd be interested in an
> >example of one which exhibited that behavior and bonk the author on the 
> >head.  Its not only wrong but it leads rapidly to security holes.
> 
> emacs.  I guess you'll be bonking Richard Stallman.  But actually, emacs 
> only does that in interactive mode, where it is a convenience not to 
> have to do all the backspacing to get rid of the current default path... 

Because its SO DIFFICULT to type ctrl-a ctrl-k.  *Stallman bonk*  Then again,
the guy does have severe RSS.  Anyhow, its not nearly as critical since
that behavior is interactive and transparent.


> >     my $path = "/foo/bar/$user_input";
> >
> >If $user_input = '/etc/passwd' and multiple slashes are interpreted as
> >the top level directory then I can now access any file on the filesystem.
> 
> It seems like old versions of DOS did exactly this, but I no longer have 
> them installed for testing.

"old versions of DOS" and "wrong" go hand in hand. :)


> Well, I actually agree that reducing // (and \\) to / (and \) is the 
> right thing to do, except for \\ at the beginning of UNC names on 
> Windows.  And that trailing / (and \) should be removed when removing 
> the filename.  After all, the person that asked for the filename removal 
> knows they are getting a directory name back, and knows it won't have a 
> trailing / (or \), and if they want to disambiguate it for display or 
> for passing to other software, it is easy enough to   .'/'

To provide a counter argument:

The person that asked for the filename removal knows it will have 
a trailing / (or \) and now doesn't have to worry about it being 
ambiguous at all.  Its easy enough to s{/$}{};

Basically it boils down to your basic "good neighbor" policy of being
strict in what you emit.  Don't remove information if you don't have to.
Don't leave it on the lap of the caller to clean up your mess.

OTOH Unix tradition is overwhelmingly in favor of stripping trailing slashes,
I haven't been bitten in the ass on this one yet and it just complicates an
already complicated issue.


> I just wanted to raise some other strange issues to make sure you were 
> thinking about them, and handling them appropriately and that 
> File::Basename and dirname and fileparse will all agree in all these 
> cases once you get done improving them.

That's the wierdest part.  That fileparse and dirname give separate results.


-- 
Michael G Schwern     [EMAIL PROTECTED]     http://www.pobox.com/~schwern
Reality is that which, when you stop believing in it, doesn't go away.
        -- Phillip K. Dick

Reply via email to