Re: [patch] libstdc++/67173 Fix filesystem::canonical for Solaris 10.

2015-09-23 Thread Jonathan Wakely
On 17/09/15 09:37 -0600, Martin Sebor wrote: On 09/17/2015 05:16 AM, Jonathan Wakely wrote: On 16/09/15 17:42 -0600, Martin Sebor wrote: I see now the first exists test will detect symlink loops in the original path. But I'm not convinced there isn't a corner case that's subject to a TOCTOU rac

Re: [patch] libstdc++/67173 Fix filesystem::canonical for Solaris 10.

2015-09-17 Thread Jonathan Wakely
On 17/09/15 21:25 +0200, Andreas Schwab wrote: Jonathan Wakely writes: + p = "/dev/stdin"; + if (exists(p)) +{ + auto p2 = canonical(p); + if (is_symlink(p)) +VERIFY( p != p2 ); + else +VERIFY( p == p2 ); + VERIFY( canonical(p2) == p2 ); This fails i

Re: [patch] libstdc++/67173 Fix filesystem::canonical for Solaris 10.

2015-09-17 Thread Andreas Schwab
Jonathan Wakely writes: > + p = "/dev/stdin"; > + if (exists(p)) > +{ > + auto p2 = canonical(p); > + if (is_symlink(p)) > +VERIFY( p != p2 ); > + else > +VERIFY( p == p2 ); > + VERIFY( canonical(p2) == p2 ); This fails if stdin is a pipe, which doesn't

Re: [patch] libstdc++/67173 Fix filesystem::canonical for Solaris 10.

2015-09-17 Thread Martin Sebor
On 09/17/2015 05:16 AM, Jonathan Wakely wrote: On 16/09/15 17:42 -0600, Martin Sebor wrote: I see now the first exists test will detect symlink loops in the original path. But I'm not convinced there isn't a corner case that's subject to a TOCTOU race condition between the first exists test and

Re: [patch] libstdc++/67173 Fix filesystem::canonical for Solaris 10.

2015-09-17 Thread Jonathan Wakely
On 16/09/15 23:50 +0100, Jonathan Wakely wrote: On 16/09/15 19:58 +0100, Jonathan Wakely wrote: commit ef25038796485298ff8f040bc79e0d9a371171fa Author: Jonathan Wakely Date: Wed Sep 16 18:07:32 2015 +0100 Implement filesystem::canonical() without realpath PR libstdc++/67173

Re: [patch] libstdc++/67173 Fix filesystem::canonical for Solaris 10.

2015-09-17 Thread Jonathan Wakely
On 17/09/15 12:16 +0100, Jonathan Wakely wrote: On 16/09/15 17:42 -0600, Martin Sebor wrote: I see now the first exists test will detect symlink loops in the original path. But I'm not convinced there isn't a corner case that's subject to a TOCTOU race condition between the first exists test and

Re: [patch] libstdc++/67173 Fix filesystem::canonical for Solaris 10.

2015-09-17 Thread Jonathan Wakely
On 17/09/15 12:16 +0100, Jonathan Wakely wrote: So if we use a counter, what's a sane maximum? Is MAXSYMLINKS in the value the kernel uses? 20 seems quite low, I was thinking of a much higher number. Until very recently Linux seemed to hardcode it to 40: https://github.com/torvalds/linux/blob/

Re: [patch] libstdc++/67173 Fix filesystem::canonical for Solaris 10.

2015-09-17 Thread Jonathan Wakely
On 16/09/15 17:42 -0600, Martin Sebor wrote: I see now the first exists test will detect symlink loops in the original path. But I'm not convinced there isn't a corner case that's subject to a TOCTOU race condition between the first exists test and the while loop during which a symlink loop can b

Re: [patch] libstdc++/67173 Fix filesystem::canonical for Solaris 10.

2015-09-16 Thread Martin Sebor
On 09/16/2015 04:17 PM, Jonathan Wakely wrote: On 16/09/15 16:04 -0600, Martin Sebor wrote: Tested powerpc64le-linux, x86_64-dragonfly4.1 and x86_64-netbsd5.1, do you see any reason not to commit this for now? I see only a couple of potential problems: a missing test for PATH_MAX in the unlike

Re: [patch] libstdc++/67173 Fix filesystem::canonical for Solaris 10.

2015-09-16 Thread Jonathan Wakely
On 16/09/15 19:58 +0100, Jonathan Wakely wrote: commit ef25038796485298ff8f040bc79e0d9a371171fa Author: Jonathan Wakely Date: Wed Sep 16 18:07:32 2015 +0100 Implement filesystem::canonical() without realpath PR libstdc++/67173 * acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS)

Re: [patch] libstdc++/67173 Fix filesystem::canonical for Solaris 10.

2015-09-16 Thread Jonathan Wakely
On 16/09/15 16:04 -0600, Martin Sebor wrote: Tested powerpc64le-linux, x86_64-dragonfly4.1 and x86_64-netbsd5.1, do you see any reason not to commit this for now? I see only a couple of potential problems: a missing test for PATH_MAX in the unlikely event it's not defined (or is obscenely In

Re: [patch] libstdc++/67173 Fix filesystem::canonical for Solaris 10.

2015-09-16 Thread Martin Sebor
Tested powerpc64le-linux, x86_64-dragonfly4.1 and x86_64-netbsd5.1, do you see any reason not to commit this for now? I see only a couple of potential problems: a missing test for PATH_MAX in the unlikely event it's not defined (or is obscenely large), and a missing check to avoid infinite loops

Re: [patch] libstdc++/67173 Fix filesystem::canonical for Solaris 10.

2015-09-16 Thread Jonathan Wakely
On 16/09/15 11:36 -0600, Martin Sebor wrote: It turns out I was wrong about BSD traditionally supporting realpath(path, NULL), it first appeared in these relatively recent versions: FreeBSD 9.0 OpenBSD 5.0 NetBSD 6.1 Like Solaris 11, some of them still define _POSIX_VERSION=200112L even though

Re: [patch] libstdc++/67173 Fix filesystem::canonical for Solaris 10.

2015-09-16 Thread Martin Sebor
It turns out I was wrong about BSD traditionally supporting realpath(path, NULL), it first appeared in these relatively recent versions: FreeBSD 9.0 OpenBSD 5.0 NetBSD 6.1 Like Solaris 11, some of them still define _POSIX_VERSION=200112L even though they support passing NULL, so we could hardco

Re: [patch] libstdc++/67173 Fix filesystem::canonical for Solaris 10.

2015-09-16 Thread Jonathan Wakely
On 16/09/15 17:02 +0100, Jonathan Wakely wrote: I don't know how to use _XOPEN_VERSION or _POSIX_VERSION to check for a suitable realpath without defining one of those feature-test macros, which then breaks other things. I suppose we could also define _NETBSD_SOURCE manually, which is basically

Re: [patch] libstdc++/67173 Fix filesystem::canonical for Solaris 10.

2015-09-16 Thread Jonathan Wakely
On 16/09/15 15:42 +0100, Jonathan Wakely wrote: @@ -22,6 +22,8 @@ // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . +#define _XOPEN_SOURCE 700 + #include #include #include Unfortunately this completely breaks NetBSD, because defining

Re: [patch] libstdc++/67173 Fix filesystem::canonical for Solaris 10.

2015-09-16 Thread Jonathan Wakely
On 12/09/15 12:07 -0600, Martin Sebor wrote: On 09/12/2015 04:09 AM, Jonathan Wakely wrote: On 11 September 2015 at 18:39, Martin Sebor wrote: On 09/11/2015 08:21 AM, Jonathan Wakely wrote: Solaris 10 doesn't follow POSIX in accepting a null pointer as the second argument to realpath(), so al

Re: [patch] libstdc++/67173 Fix filesystem::canonical for Solaris 10.

2015-09-12 Thread Martin Sebor
On 09/12/2015 12:07 PM, Martin Sebor wrote: On 09/12/2015 04:09 AM, Jonathan Wakely wrote: On 11 September 2015 at 18:39, Martin Sebor wrote: On 09/11/2015 08:21 AM, Jonathan Wakely wrote: Solaris 10 doesn't follow POSIX in accepting a null pointer as the second argument to realpath(), so all

Re: [patch] libstdc++/67173 Fix filesystem::canonical for Solaris 10.

2015-09-12 Thread Martin Sebor
On 09/12/2015 04:09 AM, Jonathan Wakely wrote: On 11 September 2015 at 18:39, Martin Sebor wrote: On 09/11/2015 08:21 AM, Jonathan Wakely wrote: Solaris 10 doesn't follow POSIX in accepting a null pointer as the second argument to realpath(), so allocate a buffer for it. FWIW, the NULL requ

Re: [patch] libstdc++/67173 Fix filesystem::canonical for Solaris 10.

2015-09-12 Thread Jonathan Wakely
On 11 September 2015 at 18:39, Martin Sebor wrote: > On 09/11/2015 08:21 AM, Jonathan Wakely wrote: >> >> Solaris 10 doesn't follow POSIX in accepting a null pointer as the >> second argument to realpath(), so allocate a buffer for it. > > > FWIW, the NULL requirement is new in Issue 7. In Issue 6,

Re: [patch] libstdc++/67173 Fix filesystem::canonical for Solaris 10.

2015-09-11 Thread Martin Sebor
On 09/11/2015 08:21 AM, Jonathan Wakely wrote: Solaris 10 doesn't follow POSIX in accepting a null pointer as the second argument to realpath(), so allocate a buffer for it. FWIW, the NULL requirement is new in Issue 7. In Issue 6, the behavior is implementation-defined, and before then it was

[patch] libstdc++/67173 Fix filesystem::canonical for Solaris 10.

2015-09-11 Thread Jonathan Wakely
Solaris 10 doesn't follow POSIX in accepting a null pointer as the second argument to realpath(), so allocate a buffer for it. Tested x86_64-linux, committed to trunk. commit ed4023452f85f6c745ce473b2503f4e46fb02cd9 Author: Jonathan Wakely Date: Fri Sep 11 15:19:27 2015 +0100 Fix filesy