From: Tom Lane <tgl@sss.pgh.pa.us>
To: wangsh.fnst@fujitsu.com <wangsh.fnst@fujitsu.com>
Cc: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: michael@paquier.xyz <michael@paquier.xyz>
Cc: andrew@dunslane.net <andrew@dunslane.net>
Cc: pgsql-hackers@lists.postgresql.org <pgsql-hackers@lists.postgresql.org>
Subject: Re: drop tablespace failed when location contains .. on win32
Date: Wed, 10 Nov 2021 17:43:31 -0500
Message-ID: <1479474.1636584211@sss.pgh.pa.us> (raw)
In-Reply-To: <OS3PR01MB71599B537F68956616FCC4BAF2A69@OS3PR01MB7159.jpnprd01.prod.outlook.com>
References: <5dc0799e-82ab-cc86-6dc6-915412f2585a@dunslane.net>
<TY2PR01MB421975D9184BAF6FBAC2262BF2D89@TY2PR01MB4219.jpnprd01.prod.outlook.com>
<YT74jO2LwChTmE58@paquier.xyz>
<20210913.173629.689388354506122738.horikyota.ntt@gmail.com>
<OS3PR01MB71599B537F68956616FCC4BAF2A69@OS3PR01MB7159.jpnprd01.prod.outlook.com>
"wangsh.fnst@fujitsu.com" <wangsh.fnst@fujitsu.com> writes:
> I don't know this. After some test, I think it's better to consider '/hoge/foo/bar'
> as a absolute path.
Agreed. I think we are considering "absolute path" here as a
syntactic concept; Windows' weird rules about drive letters
don't really matter for the purposes of path canonicalization.
> 0001 and 0002 are the are the bugfix patches.
> 0003 is the test patch what I have tested on Linux and Windows.
> Waiting for some comment.
I tried to read 0001 but really couldn't make sense of the logic
at all, because it's seriously underdocumented. At minimum you
need an API spec comment for canonicalize_path_sub, explaining
what it's supposed to do and why. This is a significant rewrite
of what was already tricky code, so we can't skimp on
documentation. I'd put some effort into choosing more descriptive
names, too ("sub" doesn't mean much, especially here where it's
not clear if it means "subroutine" or "path component").
I did notice that you dropped the separate step to collapse
adjacent separators (i.e, reduce "foo//bar" to "foo/bar"), which
seems like probably a bad idea. I think such cases might confuse
canonicalize_path_sub, and even if it manages to do the right
thing, that requirement will complicate its invariants won't it?
Another thing I happened to notice is that join_path_components
is going out of its way to not generate "foo/./bar", but if
we are fixing canonicalize_path to be able to delete the "./",
that seems like a waste of code now.
I am not entirely convinced that 0002 isn't re-introducing the
security hole that the existing code seeks to plug. That one
is going to require more justification.
I concur with the upthread comments that there's little chance
we'll commit 0003 as-is; the code-to-benefit ratio is too high.
Instead, you might consider adding test_canonicalize_path in
src/test/regress/regress.c, and then adding a smaller number
of regression test cases using that.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, wangsh.fnst@fujitsu.com, horikyota.ntt@gmail.com, michael@paquier.xyz, andrew@dunslane.net
Subject: Re: drop tablespace failed when location contains .. on win32
In-Reply-To: <1479474.1636584211@sss.pgh.pa.us>
References: <5dc0799e-82ab-cc86-6dc6-915412f2585a@dunslane.net> <TY2PR01MB421975D9184BAF6FBAC2262BF2D89@TY2PR01MB4219.jpnprd01.prod.outlook.com> <YT74jO2LwChTmE58@paquier.xyz> <20210913.173629.689388354506122738.horikyota.ntt@gmail.com> <OS3PR01MB71599B537F68956616FCC4BAF2A69@OS3PR01MB7159.jpnprd01.prod.outlook.com> <1479474.1636584211@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox