Re: Bug in canonicalize_path() - Mailing list pgsql-patches

From Bruce Momjian
Subject Re: Bug in canonicalize_path()
Date
Msg-id 200508120239.j7C2dUF06142@candle.pha.pa.us
Whole thread Raw
In response to Re: Bug in canonicalize_path()  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Bug in canonicalize_path()
Re: Bug in canonicalize_path()
List pgsql-patches
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > Yep, it is a bug on 8.0.X.  Are you suggesting a backpatch?  We can do
> > it.  Any objections?
>
> I think he's suggesting that we depend on GetFullPathName(), which seems
> a bit pointless considering we have to write the code anyway for other
> platforms.

Oh.

> I didn't much like the patch as-is; we should think a little harder
> about fixing the logic properly.

I thought about it.  Here is where we get stuck:

    usr/local/../../.. has to return  ..

Yuck.  If it an absolute path like /usr, you are fine.

In my first attempt, I counted the number of ".." groups, then went up
to remove each "..", and them remove a regular directory for each "..".
And then you have this case:

    /usr/local/../bin/../..

Here you hit the first ".." as you are going up.  It just seemed like a
lost cause.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: Bug in canonicalize_path()
Next
From: "uniware"
Date:
Subject: Re: Bug in canonicalize_path()