Re: Bug in canonicalize_path()

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: William ZHANG <uniware(at)zedware(dot)org>, pgsql-patches(at)postgresql(dot)org
Subject: Re: Bug in canonicalize_path()
Date: 2005-08-12 02:39:30
Message-ID: 200508120239.j7C2dUF06142@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)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(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message uniware 2005-08-12 02:42:05 Re: Bug in canonicalize_path()
Previous Message Tom Lane 2005-08-12 02:31:46 Re: Bug in canonicalize_path()