Re: drop tablespace failed when location contains .. on win32

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: "wangsh.fnst@fujitsu.com" <wangsh.fnst@fujitsu.com>, Julien Rouhaud <rjuju123@gmail.com>, Kyotaro Horiguchi <horikyota.ntt@gmail.com>, "andrew@dunslane.net" <andrew@dunslane.net>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Date: 2022-01-31T08:15:33Z
Lists: pgsql-hackers
On Sun, Jan 30, 2022 at 04:50:03PM -0500, Tom Lane wrote:
> Here's a revised patch version that does it like that.  I also
> reviewed and simplified the canonicalize_path logic.  I think
> this is committable.

Thanks for the updated version.  The range of the tests looks fine
enough, and the CF bot does not complain.  The code is
straight-forward and pretty clear in terms of the handling of ".",
".." and the N-depth handling necessary.

Should we have tests for WIN32 (aka for driver letters and "//")?
This could be split into its own separate test file to limit the
damage with the alternate outputs, and the original complain was from
there.

> (I suspect that adminpack's checks for unsafe file names could
> now be simplified substantially, because many of the corner cases
> it worries about are no longer possible, as evidenced by the change
> in error message there.  I've not pursued that, however.)

Fine by me to let this part for later.
--
Michael

Commits

  1. Simplify coding around path_contains_parent_reference().

  2. Make canonicalize_path() more canonical.