From unknown Sun Jun 22 22:41:47 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#10472 <10472@debbugs.gnu.org> To: bug#10472 <10472@debbugs.gnu.org> Subject: Status: `realpath --relative-to= /` outputs inconsistent trailing slash Reply-To: bug#10472 <10472@debbugs.gnu.org> Date: Mon, 23 Jun 2025 05:41:47 +0000 retitle 10472 `realpath --relative-to=3D /` outputs inconsistent trai= ling slash reassign 10472 coreutils submitter 10472 Mike Frysinger severity 10472 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 10 15:16:27 2012 Received: (at submit) by debbugs.gnu.org; 10 Jan 2012 20:16:28 +0000 Received: from localhost ([127.0.0.1]:52836 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rki7P-0005MV-6i for submit@debbugs.gnu.org; Tue, 10 Jan 2012 15:16:27 -0500 Received: from eggs.gnu.org ([140.186.70.92]:38586) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rki7M-0005MK-Gz for submit@debbugs.gnu.org; Tue, 10 Jan 2012 15:16:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rki6z-0000cB-FB for submit@debbugs.gnu.org; Tue, 10 Jan 2012 15:16:02 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([140.186.70.17]:57994) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rki6z-0000c5-Di for submit@debbugs.gnu.org; Tue, 10 Jan 2012 15:16:01 -0500 Received: from eggs.gnu.org ([140.186.70.92]:45191) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rki6y-0001cj-J2 for bug-coreutils@gnu.org; Tue, 10 Jan 2012 15:16:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rki6x-0000br-CD for bug-coreutils@gnu.org; Tue, 10 Jan 2012 15:16:00 -0500 Received: from smtp.gentoo.org ([140.211.166.183]:34177) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rki6x-0000bk-01 for bug-coreutils@gnu.org; Tue, 10 Jan 2012 15:15:59 -0500 Received: from vapier.localnet (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 328A21B401A for ; Tue, 10 Jan 2012 20:15:58 +0000 (UTC) From: Mike Frysinger Organization: wh0rd.org To: bug-coreutils@gnu.org Subject: `realpath --relative-to= /` outputs inconsistent trailing slash Date: Tue, 10 Jan 2012 15:15:57 -0500 User-Agent: KMail/1.13.7 (Linux/3.2.0; KDE/4.6.5; x86_64; ; ) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart3252624.fyXcgimm3O"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <201201101515.58406.vapier@gentoo.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -3.4 (---) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.4 (---) --nextPart3252624.fyXcgimm3O Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable first some examples that look fine ... these all output the same thing: realpath --relative-to=3D/usr /usr/bin realpath --relative-to=3D/usr/ /usr/bin realpath --relative-to=3D/usr /usr/bin/ realpath --relative-to=3D/usr/ /usr/bin/ which is to say, they show: bin as does these: realpath --relative-to=3D/usr/bin /usr realpath --relative-to=3D/usr/bin/ /usr realpath --relative-to=3D/usr/bin /usr/ realpath --relative-to=3D/usr/bin/ /usr/ which is to say, they show: .. as does these: realpath --relative-to=3D/ /usr realpath --relative-to=3D/ /usr/ which is to say, they show: .. however, if the last argument is just the root path: realpath --relative-to=3D/usr / realpath --relative-to=3D/usr/ / we end up with a trailing slash: ../ for consistency, i don't think that should be the case (reported by Ulrich M=FCller via https://bugs.gentoo.org/398339) =2Dmike --nextPart3252624.fyXcgimm3O Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) iQIcBAABAgAGBQJPDJx+AAoJEEFjO5/oN/WB+MsQANDB6bgrWR7EAL0hOqCW2g9C NVdRkuJ911pn+XNKoCXQ0ANI1XlVbHOf8W4C/5iX7BF1apFGtzZcn6gWu7Oz7r4b NmMCo1fi7I7mL0VbviWZJJX89drIY6E16snX7paNJ/s/XeePBKoySP14qPAvHkZU 7BUp6NPpqeBU574XHJW6BminUZuqF3Oce+gCQ0+/FLYy4vK8Wj8uzIylKCZqshmT eelf4GRcKSrfIVBqrSh3JBEUncfSgaYO8TBtaBqMBc67NqvXRboQfg8CNgxAQ4xN eNfrLRnBiMwM1hGwtQ99wBnpc0pNq4N5v1rNSraKHuK3XtE7vKbEfqZHvaywVBVr LHA9ej20qQg05Awt5hal+N0WvZ8+B4B73FlNDAnOQFCLoh9J1G7Yq43juydPk1NF cb/RzYP68HEo4WFMjmLmQslcYkNYRC2sCRr5BvmUjoolgYSqmEJARBuTxxZek0ki AkWz4/gENZ6uMUwNYCHKb1gdsgjOEhqJExKmMmsgbIhFWBnu07la/1NFkXXzC5wJ SxwqO5iKxRad5dgMy6tHCHUFwQiGAfnGDvQ6OcREU2cC85uf8oSHHocGfO6KM3Gs 37pxtRvQp7pz2kffkvL0L76ICUFJjfA3372cX0+H9vPaqKj8aEGupnREvDMyoT0C i9bwMIQEwew5mqnItotG =ks1Q -----END PGP SIGNATURE----- --nextPart3252624.fyXcgimm3O-- From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 10 16:54:09 2012 Received: (at submit) by debbugs.gnu.org; 10 Jan 2012 21:54:09 +0000 Received: from localhost ([127.0.0.1]:52887 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rkjdw-0007an-1n for submit@debbugs.gnu.org; Tue, 10 Jan 2012 16:54:08 -0500 Received: from eggs.gnu.org ([140.186.70.92]:33126) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rkjdu-0007ae-D1 for submit@debbugs.gnu.org; Tue, 10 Jan 2012 16:54:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RkjdX-00010j-Ra for submit@debbugs.gnu.org; Tue, 10 Jan 2012 16:53:44 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([140.186.70.17]:58845) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkjdX-00010P-Ps for submit@debbugs.gnu.org; Tue, 10 Jan 2012 16:53:43 -0500 Received: from eggs.gnu.org ([140.186.70.92]:54510) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkjdW-000496-TS for bug-coreutils@gnu.org; Tue, 10 Jan 2012 16:53:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RkjdW-0000wn-24 for bug-coreutils@gnu.org; Tue, 10 Jan 2012 16:53:42 -0500 Received: from smtp.gentoo.org ([140.211.166.183]:41335) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RkjdV-0000uK-QI for bug-coreutils@gnu.org; Tue, 10 Jan 2012 16:53:42 -0500 Received: from vapier.localnet (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 34F031B4034; Tue, 10 Jan 2012 21:53:40 +0000 (UTC) From: Mike Frysinger Organization: wh0rd.org To: bug-coreutils@gnu.org Subject: Re: bug#10472: `realpath --relative-to= /` outputs inconsistent trailing slash Date: Tue, 10 Jan 2012 16:53:41 -0500 User-Agent: KMail/1.13.7 (Linux/3.2.0; KDE/4.6.5; x86_64; ; ) References: <201201101515.58406.vapier@gentoo.org> In-Reply-To: <201201101515.58406.vapier@gentoo.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart2575263.fSxOSEXLZU"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <201201101653.41658.vapier@gentoo.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -3.4 (---) X-Debbugs-Envelope-To: submit Cc: 10472@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.4 (---) --nextPart2575263.fSxOSEXLZU Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit On Tuesday 10 January 2012 15:15:57 Mike Frysinger wrote: > as does these: > realpath --relative-to=/ /usr > realpath --relative-to=/ /usr/ > which is to say, they show: > .. sorry, typo here ... these actually output: ../usr i guess that should be just "usr". -mike --nextPart2575263.fSxOSEXLZU Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) iQIcBAABAgAGBQJPDLNlAAoJEEFjO5/oN/WBy04P/1AmlfTA+qMfiRsycLXDCDhx KKNLHskCLpZ1AMJ094GtINSZoHJ9vTl0XbgiZQCieoPakGKrdyJ8224Celv30Qe4 ds2KClALweWtU+6yn7rCNc/EqzyuqXd1Jc8k5uhSPX30g8FW4/suiXpP9LMZ07l2 zHb2n3Mwr4ZXuEa5UmBBpcMfqVNI4BiK8ZYGUGiEEJhZcXPQ9kAystRB0DcB1wWd OOBQcjSDLNMal8JTHgXHRRNBxdQl1UD8KP3T2bx/5Nj6imf5knK8/U/Mnbn/K41y EdEQvPrPzyicI7Z7+Iij8AVn96Wf6c7UPjlEYyzPkifcypbOvrTjxiytdGaJUjRZ 9rv5nmOc/WFuqPGiUVkqptgsPLuYcYnsyZUZ5owjttVlBpNmyRbrATYCNHgLCpuN nv2dUASOnfIjkxCTZ04xXBZRIX926+g55IAFVE2pMECOs7NNN2BIwAkKFeXzzQs6 tGfWwpvODGkvcDrWS8rKNr17VX3AIpV1AzEGrWdFL9VpbemoaoqIuLSYH5AQP7/8 nQ/3ZTUDphNNkiUgZSLh/PwHq46HEC4MQfwmL8i8U4oJcj0TNLh5WSHFzqoKByQb sPOJ7o7gZUlbVKHo4sUsnX0Yiqe6Q3iSoX4wbYZRQMv6KRQMUMImCgGMePj0Jdvm ufffQtQiXkHuj8M1/aif =dNCC -----END PGP SIGNATURE----- --nextPart2575263.fSxOSEXLZU-- From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 10 17:31:14 2012 Received: (at 10472) by debbugs.gnu.org; 10 Jan 2012 22:31:14 +0000 Received: from localhost ([127.0.0.1]:52932 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RkkDp-0008Tp-Rw for submit@debbugs.gnu.org; Tue, 10 Jan 2012 17:31:14 -0500 Received: from mail3.vodafone.ie ([213.233.128.45]:50099) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RkkDn-0008Tg-VN for 10472@debbugs.gnu.org; Tue, 10 Jan 2012 17:31:12 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApMBAMm7DE9tTCaR/2dsb2JhbAAMNoUPpReFKQEBAQMBIw8BRhALDQEKAgIFFgsCAgkDAgECAUUGDQEHAQGHdqVSkSmBL4JOhwCBFgSafYxJ Received: from unknown (HELO [192.168.1.79]) ([109.76.38.145]) by mail3.vodafone.ie with ESMTP; 10 Jan 2012 22:30:48 +0000 Message-ID: <4F0CBC18.2010706@draigBrady.com> Date: Tue, 10 Jan 2012 22:30:48 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 MIME-Version: 1.0 To: Mike Frysinger Subject: Re: bug#10472: `realpath --relative-to= /` outputs inconsistent trailing slash References: <201201101515.58406.vapier@gentoo.org> <201201101653.41658.vapier@gentoo.org> In-Reply-To: <201201101653.41658.vapier@gentoo.org> X-Enigmail-Version: 1.3.2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 10472 Cc: 10472@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On 01/10/2012 09:53 PM, Mike Frysinger wrote: > On Tuesday 10 January 2012 15:15:57 Mike Frysinger wrote: >> as does these: >> realpath --relative-to=/ /usr >> realpath --relative-to=/ /usr/ >> which is to say, they show: >> .. > > sorry, typo here ... these actually output: > ../usr > > i guess that should be just "usr". > -mike Agreed. python concurs too: >>> os.path.relpath(start='/usr',path='/') '..' >>> os.path.relpath(start='/',path='/usr') 'usr' Essentially in these edge cases the relative paths printed are valid, but not canonicalised. I'll fix it up. cheers, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 10 18:08:29 2012 Received: (at 10472) by debbugs.gnu.org; 10 Jan 2012 23:08:29 +0000 Received: from localhost ([127.0.0.1]:52950 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rkknp-0000rA-6N for submit@debbugs.gnu.org; Tue, 10 Jan 2012 18:08:28 -0500 Received: from smtp.gentoo.org ([140.211.166.183]:48223) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rkknm-0000r2-EU for 10472@debbugs.gnu.org; Tue, 10 Jan 2012 18:08:23 -0500 Received: from vapier.localnet (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 841121B402B; Tue, 10 Jan 2012 23:07:59 +0000 (UTC) From: Mike Frysinger Organization: wh0rd.org To: =?iso-8859-1?q?P=E1draig_Brady?= Subject: Re: bug#10472: `realpath --relative-to= /` outputs inconsistent trailing slash Date: Tue, 10 Jan 2012 18:08:00 -0500 User-Agent: KMail/1.13.7 (Linux/3.2.0; KDE/4.6.5; x86_64; ; ) References: <201201101515.58406.vapier@gentoo.org> <201201101653.41658.vapier@gentoo.org> <4F0CBC18.2010706@draigBrady.com> In-Reply-To: <4F0CBC18.2010706@draigBrady.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart1496829.c73zV8qGYQ"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <201201101808.01361.vapier@gentoo.org> X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: 10472 Cc: 10472@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.2 (----) --nextPart1496829.c73zV8qGYQ Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Tuesday 10 January 2012 17:30:48 P=C3=A1draig Brady wrote: > Essentially in these edge cases the relative paths > printed are valid, but not canonicalised. sure ... i think we all agree on that :) =2Dmike --nextPart1496829.c73zV8qGYQ Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) iQIcBAABAgAGBQJPDMTRAAoJEEFjO5/oN/WBJ2oP/3VyxjFm1I1KcBwCuR2eiVaD hCRc4TP1+Sxmx5rpPXm6Ny/hYTHUe41MGPijsrJHIj4qjn08YBftlQoQ0MyI6YXz J3EQByeAdwmifj6qXx5S6fVTnIYS8ptP/CzuGEw53eJDWIHBPWxBv+HRI5IsM6Jp /WqTLzvrVmUFcUBxLf11uaN/5Ww/ECeFdj+vib7oPMOsgPVfgkmR2vValD3hSTNz 6AqNfbfvxwxH6lwxyrsHQ/7rpuOf5C/RM9nCIA3oLb0Jv4nsIcXcAlF0YMiXlrqa 89ONdMyIrqaaHG6Os2kjTmpXuJWuu/tqiHSly5UItU6ZjZN6mKcYtYT2SQ7H16WU oJbQuryF0c7KdwdaSKkx/4UBztFsCFKT4OjPk+i+gJJISZM8jNRUF5U28ftpN7F6 WohYeuY7+ONYLHQDGv3E2acyVY7pvFBALf8PuPoafbtMQwHa4utbG1GIehBvPnRr pa6cTToibABnjSaRDAD+XrNz6j409o703plnTXIWGhFSqBlU/t22ekXwrGLfOWC2 E8B1tfPwOL1+604ndikB+5+4rGTvfbc5yFH/SbbXm9H99bum8X+UGqcGvvd9KKtf B2TyiUTTtfHTOxbTZhj7GF0wVBLhgZOctwqLhdLL84AdjqNzbZEFBBebyW5itB4d JUsfBVFptj3NF9OG4csi =Fy4Q -----END PGP SIGNATURE----- --nextPart1496829.c73zV8qGYQ-- From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 25 11:55:45 2012 Received: (at 10472-done) by debbugs.gnu.org; 25 Jan 2012 16:55:45 +0000 Received: from localhost ([127.0.0.1]:43550 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rq68P-0008Pq-2l for submit@debbugs.gnu.org; Wed, 25 Jan 2012 11:55:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49361) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rq68L-0008Pf-4H for 10472-done@debbugs.gnu.org; Wed, 25 Jan 2012 11:55:42 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0PGtCmP022877 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 25 Jan 2012 11:55:12 -0500 Received: from [10.36.116.41] (ovpn-116-41.ams2.redhat.com [10.36.116.41]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q0PGt9AF012200 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Wed, 25 Jan 2012 11:55:11 -0500 Message-ID: <4F2033ED.5070109@draigBrady.com> Date: Wed, 25 Jan 2012 16:55:09 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 MIME-Version: 1.0 To: Mike Frysinger Subject: Re: bug#10472: `realpath --relative-to= /` outputs inconsistent trailing slash References: <201201101515.58406.vapier@gentoo.org> <201201101653.41658.vapier@gentoo.org> <4F0CBC18.2010706@draigBrady.com> In-Reply-To: <4F0CBC18.2010706@draigBrady.com> X-Enigmail-Version: 1.3.2 Content-Type: multipart/mixed; boundary="------------090103070605030206030108" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Spam-Score: -6.9 (------) X-Debbugs-Envelope-To: 10472-done Cc: 10472-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) This is a multi-part message in MIME format. --------------090103070605030206030108 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mx1.redhat.com id q0PGtCmP022877 On 01/10/2012 10:30 PM, P=C3=A1draig Brady wrote: > On 01/10/2012 09:53 PM, Mike Frysinger wrote: >> On Tuesday 10 January 2012 15:15:57 Mike Frysinger wrote: >>> as does these: >>> realpath --relative-to=3D/ /usr >>> realpath --relative-to=3D/ /usr/ >>> which is to say, they show: >>> .. >> >> sorry, typo here ... these actually output: >> ../usr >> >> i guess that should be just "usr". >> -mike >=20 > Agreed. python concurs too: >=20 >>>> os.path.relpath(start=3D'/usr',path=3D'/') > '..' >>>> os.path.relpath(start=3D'/',path=3D'/usr') > 'usr' >=20 > Essentially in these edge cases the relative paths > printed are valid, but not canonicalised. >=20 > I'll fix it up. Proposed fix attached. cheers, P=C3=A1draig. --------------090103070605030206030108 Content-Type: text/plain; name="relpath-edge-cases.diff" Content-Disposition: attachment; filename="relpath-edge-cases.diff" Content-Transfer-Encoding: base64 RnJvbSAzYThjYzFhZjE1ZjBjOWM2YTcxYzVhYmM5MjE5MjM3ZjE2MTNlOGNmIE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiA9P1VURi04P3E/UD1DMz1BMWRyYWlnPTIwQnJhZHk/ PSA8UEBkcmFpZ0JyYWR5LmNvbT4KRGF0ZTogV2VkLCAyNSBKYW4gMjAxMiAxNjo0Mjo0MiAr MDAwMApTdWJqZWN0OiBbUEFUQ0hdIHJlYWxwYXRoOiByZW1vdmUgZXh0cmFuZW91cyAnLycg Zm9yIC0tcmVsYXRpdmUtdG8gZWRnZSBjYXNlcwoKKiBzcmMvcmVhbHBhdGguYyAocGF0aF9j b21tb25fcHJlZml4KTogQmUgY29uc2lzdGVudCBhbmQKYWx3YXlzIGluY2x1ZGUgYSBsZWFk aW5nICcvJyBpbiB0aGUgY291bnQgcmV0dXJuZWQuCihyZWxwYXRoKTogQWNjb3VudCBmb3Ig dGhlIGNoYW5nZSBpbiBwYXRoX2NvbW1vbl9wcmVmaXgoKQphbmQgYXZvaWQgb3V0cHV0dGlu ZyBleHRyYSAnLycgY2hhcnMgaW4gcmVsYXRpdmUgcGF0aHMgdGhhdApzcGFuIHRoZSByb290 IGRpci4KKiB0ZXN0cy9taXNjL3JlYWxwYXRoOiBBZGQgdGhlIHR3byByZXBvcnRlZCBjYXNl cy4KUmVwb3J0ZWQgYnkgTWlrZSBGcnlzaW5nZXIKLS0tCiBzcmMvcmVhbHBhdGguYyAgICAg IHwgICAxNiArKysrKysrKysrKy0tLS0tCiB0ZXN0cy9taXNjL3JlYWxwYXRoIHwgICAxMSAr KysrKysrKy0tLQogMiBmaWxlcyBjaGFuZ2VkLCAxOSBpbnNlcnRpb25zKCspLCA4IGRlbGV0 aW9ucygtKQoKZGlmZiAtLWdpdCBhL3NyYy9yZWFscGF0aC5jIGIvc3JjL3JlYWxwYXRoLmMK aW5kZXggYjM5ZjdiZi4uOGEwN2FiNiAxMDA2NDQKLS0tIGEvc3JjL3JlYWxwYXRoLmMKKysr IGIvc3JjL3JlYWxwYXRoLmMKQEAgLTEzNiw3ICsxMzYsNyBAQCBwYXRoX2NvbW1vbl9wcmVm aXggKGNvbnN0IGNoYXIgKnBhdGgxLCBjb25zdCBjaGFyICpwYXRoMikKICAgICAgIGlmICgq cGF0aDEgIT0gKnBhdGgyKQogICAgICAgICBicmVhazsKICAgICAgIGlmICgqcGF0aDEgPT0g Jy8nKQotICAgICAgICByZXQgPSBpOworICAgICAgICByZXQgPSBpICsgMTsKICAgICAgIHBh dGgxKys7CiAgICAgICBwYXRoMisrOwogICAgICAgaSsrOwpAQCAtMTcxLDExICsxNzEsMTYg QEAgcmVscGF0aCAoY29uc3QgY2hhciAqY2FuX2ZuYW1lKQogICAgICAgY29uc3QgY2hhciAq cmVsdG9fc3VmZml4ID0gY2FuX3JlbGF0aXZlX3RvICsgY29tbW9uX2luZGV4OwogICAgICAg Y29uc3QgY2hhciAqZm5hbWVfc3VmZml4ID0gY2FuX2ZuYW1lICsgY29tbW9uX2luZGV4Owog CisgICAgICAvKiBza2lwIG92ZXIgZXh0cmFuZW91cyAnLycuICAqLworICAgICAgaWYgKCpy ZWx0b19zdWZmaXggPT0gJy8nKQorICAgICAgICByZWx0b19zdWZmaXgrKzsKKyAgICAgIGlm ICgqZm5hbWVfc3VmZml4ID09ICcvJykKKyAgICAgICAgZm5hbWVfc3VmZml4Kys7CisKICAg ICAgIC8qIFJlcGxhY2UgcmVtYWluaW5nIGNvbXBvbmVudHMgb2YgLS1yZWxhdGl2ZS10byB3 aXRoICcuLicsIHRvIGdldAogICAgICAgICAgdG8gYSBjb21tb24gZGlyZWN0b3J5LiAgVGhl biBvdXRwdXQgdGhlIHJlbWFpbmRlciBvZiBmbmFtZS4gICovCiAgICAgICBpZiAoKnJlbHRv X3N1ZmZpeCkKICAgICAgICAgewotICAgICAgICAgICsrcmVsdG9fc3VmZml4OwogICAgICAg ICAgIHByaW50ZiAoIiVzIiwgIi4uIik7CiAgICAgICAgICAgZm9yICg7ICpyZWx0b19zdWZm aXg7ICsrcmVsdG9fc3VmZml4KQogICAgICAgICAgICAgewpAQCAtMTgzLDE0ICsxODgsMTUg QEAgcmVscGF0aCAoY29uc3QgY2hhciAqY2FuX2ZuYW1lKQogICAgICAgICAgICAgICAgIHBy aW50ZiAoIiVzIiwgIi8uLiIpOwogICAgICAgICAgICAgfQogCi0gICAgICAgICAgcHJpbnRm ICgiJXMiLCBmbmFtZV9zdWZmaXgpOworICAgICAgICAgIGlmICgqZm5hbWVfc3VmZml4KQor ICAgICAgICAgICAgcHJpbnRmICgiLyVzIiwgZm5hbWVfc3VmZml4KTsKICAgICAgICAgfQog ICAgICAgZWxzZQogICAgICAgICB7CiAgICAgICAgICAgaWYgKCpmbmFtZV9zdWZmaXgpCi0g ICAgICAgICAgICBwcmludGYgKCIlcyIsICsrZm5hbWVfc3VmZml4KTsKKyAgICAgICAgICAg IHByaW50ZiAoIiVzIiwgZm5hbWVfc3VmZml4KTsKICAgICAgICAgICBlbHNlCi0gICAgICAg ICAgICBwcmludGYgKCIlYyIsICcuJyk7CisgICAgICAgICAgICBwdXRjaGFyICgnLicpOwog ICAgICAgICB9CiAKICAgICAgIHB1dGNoYXIgKHVzZV9udWxzID8gJ1wwJyA6ICdcbicpOwpk aWZmIC0tZ2l0IGEvdGVzdHMvbWlzYy9yZWFscGF0aCBiL3Rlc3RzL21pc2MvcmVhbHBhdGgK aW5kZXggZmIwMTM5My4uOGExZjMzNiAxMDA3NTUKLS0tIGEvdGVzdHMvbWlzYy9yZWFscGF0 aAorKysgYi90ZXN0cy9taXNjL3JlYWxwYXRoCkBAIC00MSwxMyArNDEsMTggQEAgcmVhbHBh dGggLW0gJycgJiYgZmFpbD0xCiAKICMgc3ltbGluayByZXNvbHV0aW9uCiB0aGlzPSQocmVh bHBhdGggLikKLXRlc3QgIiQocmVhbHBhdGggJHJlbGF0aXZlIGxkaXIyLy4uKSIgPSAiJHRo aXMvZGlyMSIgfHwgZmFpbD0xCi10ZXN0ICIkKHJlYWxwYXRoIC1MICRyZWxhdGl2ZSBsZGly Mi8uLikiID0gIiR0aGlzIiB8fCBmYWlsPTEKLXRlc3QgIiQocmVhbHBhdGggLXMgJHJlbGF0 aXZlIGxkaXIyKSIgPSAiJHRoaXMvbGRpcjIiIHx8IGZhaWw9MQordGVzdCAiJChyZWFscGF0 aCBsZGlyMi8uLikiID0gIiR0aGlzL2RpcjEiIHx8IGZhaWw9MQordGVzdCAiJChyZWFscGF0 aCAtTCBsZGlyMi8uLikiID0gIiR0aGlzIiB8fCBmYWlsPTEKK3Rlc3QgIiQocmVhbHBhdGgg LXMgbGRpcjIpIiA9ICIkdGhpcy9sZGlyMiIgfHwgZmFpbD0xCiAKICMgcmVsYXRpdmUgc3Ry aW5nIGhhbmRsaW5nCiB0ZXN0ICQocmVhbHBhdGggLW0gLS1yZWxhdGl2ZS10bz1wcmVmaXgg cHJlZml4ZWQvMSkgPSAnLi4vcHJlZml4ZWQvMScgfHwgZmFpbD0xCiB0ZXN0ICQocmVhbHBh dGggLW0gLS1yZWxhdGl2ZS10bz1wcmVmaXhlZCBwcmVmaXgvMSkgPSAnLi4vcHJlZml4LzEn IHx8IGZhaWw9MQogdGVzdCAkKHJlYWxwYXRoIC1tIC0tcmVsYXRpdmUtdG89cHJlZml4ZWQg cHJlZml4ZWQvMSkgPSAnMScgfHwgZmFpbD0xCiAKKyMgRW5zdXJlIG5vIHJlZHVuZGFudCB0 cmFpbGluZyAnLycgcHJlc2VudCwgYXMgd2FzIHRoZSBjYXNlIGluIHY4LjE1Cit0ZXN0ICQo cmVhbHBhdGggLXNtIC0tcmVsYXRpdmUtdG89L3VzciAvKSA9ICcuLicgfHwgZmFpbD0xCisj IEVuc3VyZSBubyByZWR1bmRhbnQgbGVhZGluZyAnLi4vJyBwcmVzZW50LCBhcyB3YXMgdGhl IGNhc2UgaW4gdjguMTUKK3Rlc3QgJChyZWFscGF0aCAtc20gLS1yZWxhdGl2ZS10bz0vIC91 c3IpID0gJ3VzcicgfHwgZmFpbD0xCisKIEV4aXQgJGZhaWwKLS0gCjEuNy42LjQKCg== --------------090103070605030206030108-- From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 25 12:10:51 2012 Received: (at 10472) by debbugs.gnu.org; 25 Jan 2012 17:10:51 +0000 Received: from localhost ([127.0.0.1]:43593 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rq6N1-0000Lq-BN for submit@debbugs.gnu.org; Wed, 25 Jan 2012 12:10:51 -0500 Received: from mx.meyering.net ([88.168.87.75]:33684) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rq6Mz-0000Li-Af for 10472@debbugs.gnu.org; Wed, 25 Jan 2012 12:10:50 -0500 Received: from rho.meyering.net (localhost.localdomain [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id 9EC45600A7; Wed, 25 Jan 2012 18:10:20 +0100 (CET) From: Jim Meyering To: 10472@debbugs.gnu.org Subject: Re: bug#10472: `realpath --relative-to= /` outputs inconsistent trailing slash In-Reply-To: <4F2033ED.5070109@draigBrady.com> (=?iso-8859-1?Q?=22P=E1drai?= =?iso-8859-1?Q?g?= Brady"'s message of "Wed, 25 Jan 2012 16:55:09 +0000") References: <201201101515.58406.vapier@gentoo.org> <201201101653.41658.vapier@gentoo.org> <4F0CBC18.2010706@draigBrady.com> <4F2033ED.5070109@draigBrady.com> Date: Wed, 25 Jan 2012 18:10:20 +0100 Message-ID: <871uqnpv2b.fsf@rho.meyering.net> Lines: 70 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 10472 Cc: P@draigBrady.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) P=E1draig Brady wrote: ... > Subject: [PATCH] realpath: remove extraneous '/' for --relative-to edge c= ases > > * src/realpath.c (path_common_prefix): Be consistent and > always include a leading '/' in the count returned. > (relpath): Account for the change in path_common_prefix() > and avoid outputting extra '/' chars in relative paths that > span the root dir. > * tests/misc/realpath: Add the two reported cases. > Reported by Mike Frysinger > --- > src/realpath.c | 16 +++++++++++----- > tests/misc/realpath | 11 ++++++++--- > 2 files changed, 19 insertions(+), 8 deletions(-) > > diff --git a/src/realpath.c b/src/realpath.c > index b39f7bf..8a07ab6 100644 > --- a/src/realpath.c > +++ b/src/realpath.c > @@ -136,7 +136,7 @@ path_common_prefix (const char *path1, const char *pa= th2) > if (*path1 !=3D *path2) > break; > if (*path1 =3D=3D '/') > - ret =3D i; > + ret =3D i + 1; > path1++; > path2++; > i++; > @@ -171,11 +171,16 @@ relpath (const char *can_fname) > const char *relto_suffix =3D can_relative_to + common_index; > const char *fname_suffix =3D can_fname + common_index; > > + /* skip over extraneous '/'. */ > + if (*relto_suffix =3D=3D '/') > + relto_suffix++; > + if (*fname_suffix =3D=3D '/') > + fname_suffix++; > + > /* Replace remaining components of --relative-to with '..', to get > to a common directory. Then output the remainder of fname. */ > if (*relto_suffix) > { > - ++relto_suffix; > printf ("%s", ".."); > for (; *relto_suffix; ++relto_suffix) > { > @@ -183,14 +188,15 @@ relpath (const char *can_fname) > printf ("%s", "/.."); > } > > - printf ("%s", fname_suffix); > + if (*fname_suffix) > + printf ("/%s", fname_suffix); > } > else > { > if (*fname_suffix) > - printf ("%s", ++fname_suffix); > + printf ("%s", fname_suffix); > else > - printf ("%c", '.'); > + putchar ('.'); > } That looks fine and passes existing and new tests (of course). Thanks. On an unrelated note, have you considered removing the remaining printf uses in favor of fputc/fputs, since they're all trivial? From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 25 13:01:03 2012 Received: (at 10472) by debbugs.gnu.org; 25 Jan 2012 18:01:04 +0000 Received: from localhost ([127.0.0.1]:43693 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rq79a-0001ZR-E0 for submit@debbugs.gnu.org; Wed, 25 Jan 2012 13:01:03 -0500 Received: from mail3.vodafone.ie ([213.233.128.45]:8400) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rq79W-0001Yw-Sb for 10472@debbugs.gnu.org; Wed, 25 Jan 2012 13:01:00 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApMBACVCIE9tTk13/2dsb2JhbAAMNqwPhSoBAQEEMgFGEAsNCwkWDwkDAgECAUUGDQEHAQHAHIkPAQQCAwkGAgQDByQCAQIBgm0NBAF4BoM1BJsXjFg Received: from unknown (HELO [192.168.1.79]) ([109.78.77.119]) by mail3.vodafone.ie with ESMTP; 25 Jan 2012 18:00:25 +0000 Message-ID: <4F204338.2070507@draigBrady.com> Date: Wed, 25 Jan 2012 18:00:24 +0000 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 MIME-Version: 1.0 To: Jim Meyering Subject: Re: bug#10472: `realpath --relative-to= /` outputs inconsistent trailing slash References: <201201101515.58406.vapier@gentoo.org> <201201101653.41658.vapier@gentoo.org> <4F0CBC18.2010706@draigBrady.com> <4F2033ED.5070109@draigBrady.com> <871uqnpv2b.fsf@rho.meyering.net> In-Reply-To: <871uqnpv2b.fsf@rho.meyering.net> X-Enigmail-Version: 1.3.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 10472 Cc: 10472@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On 01/25/2012 05:10 PM, Jim Meyering wrote: > On an unrelated note, have you considered removing the remaining > printf uses in favor of fputc/fputs, since they're all trivial? Good point. I'll undo the s/printf/putchar/ change in this patch, and do a follow up, using the lower level functions. cheers, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 25 13:43:25 2012 Received: (at 10472) by debbugs.gnu.org; 25 Jan 2012 18:43:25 +0000 Received: from localhost ([127.0.0.1]:43775 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rq7ob-0002Y0-7Y for submit@debbugs.gnu.org; Wed, 25 Jan 2012 13:43:25 -0500 Received: from mail3.vodafone.ie ([213.233.128.45]:1584) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rq7oV-0002Xi-OK for 10472@debbugs.gnu.org; Wed, 25 Jan 2012 13:43:23 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApMBALFMIE9tTk13/2dsb2JhbAAMNqwPhSoBAQEEMgFGEAsNCwkWDwkDAgECAUUGDQEHAQHAGIN+hREBBAIDCQYCBAMHJAWCbg0EAXgGgzUEmxeMWA Received: from unknown (HELO [192.168.1.79]) ([109.78.77.119]) by mail3.vodafone.ie with ESMTP; 25 Jan 2012 18:42:46 +0000 Message-ID: <4F204D25.5050101@draigBrady.com> Date: Wed, 25 Jan 2012 18:42:45 +0000 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 MIME-Version: 1.0 To: Jim Meyering Subject: Re: bug#10472: `realpath --relative-to= /` outputs inconsistent trailing slash References: <201201101515.58406.vapier@gentoo.org> <201201101653.41658.vapier@gentoo.org> <4F0CBC18.2010706@draigBrady.com> <4F2033ED.5070109@draigBrady.com> <871uqnpv2b.fsf@rho.meyering.net> <4F204338.2070507@draigBrady.com> In-Reply-To: <4F204338.2070507@draigBrady.com> X-Enigmail-Version: 1.3.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 10472 Cc: 10472@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On 01/25/2012 06:00 PM, Pádraig Brady wrote: > On 01/25/2012 05:10 PM, Jim Meyering wrote: >> On an unrelated note, have you considered removing the remaining >> printf uses in favor of fputc/fputs, since they're all trivial? > > Good point. I'll undo the s/printf/putchar/ change in this patch, > and do a follow up, using the lower level functions. The patch below, gives an 11% improvement. Tested like: seq 1000000 | sed 's|.*|/1/2/3/4/&|' > paths time xargs src/realpath -sm < paths >/dev/null time xargs src/realpath -sm --relative-to=/1/2/3 < paths >/dev/null cheers, Pádraig. diff --git a/src/realpath.c b/src/realpath.c index b03f375..2dc5e11 100644 --- a/src/realpath.c +++ b/src/realpath.c @@ -181,26 +181,27 @@ relpath (const char *can_fname) to a common directory. Then output the remainder of fname. */ if (*relto_suffix) { - printf ("%s", ".."); + fputs ("..", stdout); for (; *relto_suffix; ++relto_suffix) { if (*relto_suffix == '/') - printf ("%s", "/.."); + fputs ("/..", stdout); } if (*fname_suffix) - printf ("/%s", fname_suffix); + { + putchar ('/'); + fputs (fname_suffix, stdout); + } } else { if (*fname_suffix) - printf ("%s", fname_suffix); + fputs (fname_suffix, stdout); else - printf ("%c", '.'); + putchar ('.'); } - putchar (use_nuls ? '\0' : '\n'); - return true; } @@ -228,7 +229,9 @@ process_path (const char *fname, int can_mode) } if (!relpath (can_fname)) - printf ("%s%c", can_fname, (use_nuls ? '\0' : '\n')); + fputs (can_fname, stdout); + + putchar (use_nuls ? '\0' : '\n'); free (can_fname); From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 25 14:41:56 2012 Received: (at 10472) by debbugs.gnu.org; 25 Jan 2012 19:41:56 +0000 Received: from localhost ([127.0.0.1]:43869 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rq8jD-0004jf-5O for submit@debbugs.gnu.org; Wed, 25 Jan 2012 14:41:55 -0500 Received: from mx.meyering.net ([88.168.87.75]:34110) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rq8jA-0004jY-Pm for 10472@debbugs.gnu.org; Wed, 25 Jan 2012 14:41:53 -0500 Received: from rho.meyering.net (localhost.localdomain [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id 4010460094; Wed, 25 Jan 2012 20:41:24 +0100 (CET) From: Jim Meyering To: =?iso-8859-1?Q?P=E1draig?= Brady Subject: Re: bug#10472: `realpath --relative-to= /` outputs inconsistent trailing slash In-Reply-To: <4F204D25.5050101@draigBrady.com> (=?iso-8859-1?Q?=22P=E1drai?= =?iso-8859-1?Q?g?= Brady"'s message of "Wed, 25 Jan 2012 18:42:45 +0000") References: <201201101515.58406.vapier@gentoo.org> <201201101653.41658.vapier@gentoo.org> <4F0CBC18.2010706@draigBrady.com> <4F2033ED.5070109@draigBrady.com> <871uqnpv2b.fsf@rho.meyering.net> <4F204338.2070507@draigBrady.com> <4F204D25.5050101@draigBrady.com> Date: Wed, 25 Jan 2012 20:41:24 +0100 Message-ID: <87fwf3o9i3.fsf@rho.meyering.net> Lines: 39 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 10472 Cc: 10472@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) P=E1draig Brady wrote: > On 01/25/2012 06:00 PM, P=E1draig Brady wrote: >> On 01/25/2012 05:10 PM, Jim Meyering wrote: >>> On an unrelated note, have you considered removing the remaining >>> printf uses in favor of fputc/fputs, since they're all trivial? >> >> Good point. I'll undo the s/printf/putchar/ change in this patch, >> and do a follow up, using the lower level functions. > > The patch below, gives an 11% improvement. > Tested like: > > seq 1000000 | sed 's|.*|/1/2/3/4/&|' > paths > time xargs src/realpath -sm < paths >/dev/null > time xargs src/realpath -sm --relative-to=3D/1/2/3 < paths >/dev/null Thanks! > diff --git a/src/realpath.c b/src/realpath.c ... > @@ -181,26 +181,27 @@ relpath (const char *can_fname) ... > - putchar (use_nuls ? '\0' : '\n'); > - > return true; > } > > @@ -228,7 +229,9 @@ process_path (const char *fname, int can_mode) > } > > if (!relpath (can_fname)) > - printf ("%s%c", can_fname, (use_nuls ? '\0' : '\n')); > + fputs (can_fname, stdout); > + > + putchar (use_nuls ? '\0' : '\n'); Nice to see the "use_nuls" use factored out. With that, it is feasible to move it's declaration into main. ACK, either way. From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 30 16:11:05 2012 Received: (at 10472) by debbugs.gnu.org; 30 Jan 2012 21:11:05 +0000 Received: from localhost ([127.0.0.1]:45683 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RryVF-0005Jj-Cs for submit@debbugs.gnu.org; Mon, 30 Jan 2012 16:11:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44142) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RryVB-0005JF-O6 for 10472@debbugs.gnu.org; Mon, 30 Jan 2012 16:11:04 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0ULAkMO008662 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 30 Jan 2012 16:10:46 -0500 Received: from [10.3.113.145] (ovpn-113-145.phx2.redhat.com [10.3.113.145]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q0ULAjFM028434; Mon, 30 Jan 2012 16:10:45 -0500 Message-ID: <4F270755.7080702@redhat.com> Date: Mon, 30 Jan 2012 14:10:45 -0700 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111222 Thunderbird/9.0 MIME-Version: 1.0 To: Mike Frysinger Subject: Re: bug#10472: `realpath --relative-to= /` outputs inconsistent trailing slash References: <201201101515.58406.vapier@gentoo.org> In-Reply-To: <201201101515.58406.vapier@gentoo.org> X-Enigmail-Version: 1.3.5 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigD5EB4FD7A3F1237490C76B46" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Spam-Score: -6.9 (------) X-Debbugs-Envelope-To: 10472 Cc: 10472@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigD5EB4FD7A3F1237490C76B46 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 01/10/2012 01:15 PM, Mike Frysinger wrote: > however, if the last argument is just the root path: > realpath --relative-to=3D/usr / > realpath --relative-to=3D/usr/ / > we end up with a trailing slash: > ../ >=20 > for consistency, i don't think that should be the case >=20 > (reported by Ulrich M=FCller via https://bugs.gentoo.org/398339) Another bug, on a system where // is distinct from /: $ realpath --relative-to=3D/ //machine / // /bin machine =2E =2E bin $ realpath --relative-to=3D// //machine / // /bin machine =2E =2E bin when it should really be: $ realpath --relative-to=3D/ //machine / // /bin //machine =2E // bin $ realpath --relative-to=3D// //machine / // /bin machine / =2E /bin We need to make realpath robust to correct leading // handling; I don't know if we should follow the lead of 'dirname' in only doing it on machines where // is special, or if it is easier to make it honor POSIX by special-casing // everywhere even on machines where / and // are identical. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enigD5EB4FD7A3F1237490C76B46 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJPJwdVAAoJEKeha0olJ0Nq2sIH/RHWGYr6BZmkQ2NMxQd173Vz GtggwWODM4Fz67QxZ8CE6up9Qwj6gw7JQ2fL4ggRTEw/p+KS67/2xN7LWNHRzgT4 0fsxxM95XnKkwDaAVK71TrqZ/ESvVptTrTy09EUwoWDKT/rirMkayFtwgTy0sPG+ 9bZJKP1EuU0g/b1diulpkv8ZqluGhb0ZLmWhgByxy3IAd3b2/JDRyY6/eEQXN1lP HrVTeJdmjb8qPm7tnWofdxcE7j5zxxKuHQMUTdbyQkHtG9S/F0m/VS7v9o4jmzdY 4D2gGXamentE0vjkBI1p33r/EKWAFFpGCO8TctXvw64Zouie8aaxK5WjUxssM/0= =H5DB -----END PGP SIGNATURE----- --------------enigD5EB4FD7A3F1237490C76B46-- From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 30 17:02:25 2012 Received: (at 10472) by debbugs.gnu.org; 30 Jan 2012 22:02:25 +0000 Received: from localhost ([127.0.0.1]:45716 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RrzIs-0006W0-49 for submit@debbugs.gnu.org; Mon, 30 Jan 2012 17:02:24 -0500 Received: from mail2.vodafone.ie ([213.233.128.44]:43917) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RrzIm-0006Vd-L4 for 10472@debbugs.gnu.org; Mon, 30 Jan 2012 17:02:18 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvcCAEUSJ09tTEVT/2dsb2JhbAAMN61Vg3kBAQEEMgFGEAsNAQoJFg8JAwIBAgFFBg0BBwEBwFYEiQ6BcQEEAgECAgkCAgEGBwQGAQsJM4JyHQMMFwVSAgwrgzkEmxKMWQ Received: from unknown (HELO [192.168.1.79]) ([109.76.69.83]) by mail2.vodafone.ie with ESMTP; 30 Jan 2012 22:01:57 +0000 Message-ID: <4F271355.5060700@draigBrady.com> Date: Mon, 30 Jan 2012 22:01:57 +0000 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 MIME-Version: 1.0 To: Eric Blake Subject: Re: bug#10472: `realpath --relative-to= /` outputs inconsistent trailing slash References: <201201101515.58406.vapier@gentoo.org> <4F270755.7080702@redhat.com> In-Reply-To: <4F270755.7080702@redhat.com> X-Enigmail-Version: 1.3.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 10472 Cc: Mike Frysinger , 10472@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On 01/30/2012 09:10 PM, Eric Blake wrote: > On 01/10/2012 01:15 PM, Mike Frysinger wrote: >> however, if the last argument is just the root path: >> realpath --relative-to=/usr / >> realpath --relative-to=/usr/ / >> we end up with a trailing slash: >> ../ >> >> for consistency, i don't think that should be the case >> >> (reported by Ulrich Müller via https://bugs.gentoo.org/398339) > > Another bug, on a system where // is distinct from /: > > $ realpath --relative-to=/ //machine / // /bin > machine > . > . > bin > $ realpath --relative-to=// //machine / // /bin > machine > . > . > bin > > when it should really be: > > $ realpath --relative-to=/ //machine / // /bin > //machine > . > // > bin > $ realpath --relative-to=// //machine / // /bin > machine > / > . > /bin > > We need to make realpath robust to correct leading // handling; I don't > know if we should follow the lead of 'dirname' in only doing it on > machines where // is special, or if it is easier to make it honor POSIX > by special-casing // everywhere even on machines where / and // are > identical. So on such a machine, I guess `readlink -m //machine/` outputs '//machine'. To match up with that, I think it makes sense to only do this on systems where a double slash is significant. BTW, this is how I'm interpreting this example: > $ realpath --relative-to=// //machine / // /bin > machine > / > . > /bin I'm taking --relative-to=// to mean relative to "the network". Hence relative output will be machines on the network, while absolute are local paths. gnulib says // matters for Apollo DomainOS (too old to port to), Cygwin, and z/OS. cheers, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 30 17:22:43 2012 Received: (at 10472) by debbugs.gnu.org; 30 Jan 2012 22:22:43 +0000 Received: from localhost ([127.0.0.1]:45733 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RrzcZ-0006yu-DA for submit@debbugs.gnu.org; Mon, 30 Jan 2012 17:22:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:14408) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RrzcX-0006yj-1D for 10472@debbugs.gnu.org; Mon, 30 Jan 2012 17:22:42 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0UMMNM1020971 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 30 Jan 2012 17:22:23 -0500 Received: from [10.3.113.145] (ovpn-113-145.phx2.redhat.com [10.3.113.145]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q0UMMMg3031903; Mon, 30 Jan 2012 17:22:22 -0500 Message-ID: <4F27181E.9090705@redhat.com> Date: Mon, 30 Jan 2012 15:22:22 -0700 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111222 Thunderbird/9.0 MIME-Version: 1.0 To: =?ISO-8859-1?Q?P=E1draig_Brady?= Subject: Re: bug#10472: `realpath --relative-to= /` outputs inconsistent trailing slash References: <201201101515.58406.vapier@gentoo.org> <4F270755.7080702@redhat.com> <4F271355.5060700@draigBrady.com> In-Reply-To: <4F271355.5060700@draigBrady.com> X-Enigmail-Version: 1.3.5 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigB14145619940D14337AFDF5F" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Spam-Score: -6.9 (------) X-Debbugs-Envelope-To: 10472 Cc: Mike Frysinger , 10472@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigB14145619940D14337AFDF5F Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 01/30/2012 03:01 PM, P=E1draig Brady wrote: >> $ realpath --relative-to=3D// //machine / // /bin >> machine >> / >> . >> /bin >> >> We need to make realpath robust to correct leading // handling; I don'= t >> know if we should follow the lead of 'dirname' in only doing it on >> machines where // is special, or if it is easier to make it honor POSI= X >> by special-casing // everywhere even on machines where / and // are >> identical. >=20 > So on such a machine, I guess `readlink -m //machine/` outputs '//machi= ne'. Correct. > To match up with that, I think it makes sense to only do this on system= s > where a double slash is significant. I'm tending to agree - readlink, dirname, and realpath should all behave consistently within a single compilation of coreutils. >=20 > BTW, this is how I'm interpreting this example: >=20 >> $ realpath --relative-to=3D// //machine / // /bin >> machine >> / >> . >> /bin >=20 > I'm taking --relative-to=3D// to mean relative to "the network". > Hence relative output will be machines on the network, > while absolute are local paths. Correct. Another bug still in the latest coreutils.git, but only on platforms with distinct //: $ src/realpath / // /// / // // Oops, that last line should be /. This bug is shared by readlink: $ src/readlink -m /// // >=20 > gnulib says // matters for Apollo DomainOS (too old to port to), > Cygwin, and z/OS. And I tested on Cygwin (if it wasn't obvious :) I can try to develop patches as part of porting coreutils 8.15 to cygwin (cygwin already has a realpath(1), but it is severely limited in that it only takes one file name and no command line options on what to do with that name; I'm pretty sure that the coreutils realpath is upwards compatible with the existing cygwin realpath: http://cygwin.com/ml/cygwin-apps/2012-01/msg00080.html). --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enigB14145619940D14337AFDF5F Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJPJxgeAAoJEKeha0olJ0Nq4/4IAKOe6cKvuCk5fgot5xB/FKM4 opqGaFUvUDst6qKma5/mEYUPd36CcpqyjFq+VO0bwtxwJoHlH7wDu6qcCb7F0Q2v dK2ixUWJuHE/snCf4HZPwrgucGfUtSCNDBDNouGwfGiifnh4ctC/zdWd3aAVtPq/ 4eeVpMjJSV/QRpleKon87Z08QixffFL+fkXw2VU9zBevBmcKFuoKx84xt6QdWuOC rPAL50uH5LjDqtpqDpZpQ+1FuNyQzoZ2a4YCwo2lTrtTmulrerEURFcolhTH0jaC CKAOVMw4qertbR6cN5xsFs8heDJJdEcev9X4es17EB1rYc6oCsMCygzA1D4amlY= =vdZM -----END PGP SIGNATURE----- --------------enigB14145619940D14337AFDF5F-- From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 30 18:53:31 2012 Received: (at 10472) by debbugs.gnu.org; 30 Jan 2012 23:53:31 +0000 Received: from localhost ([127.0.0.1]:45863 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rs12R-0001SH-3Q for submit@debbugs.gnu.org; Mon, 30 Jan 2012 18:53:31 -0500 Received: from mail2.vodafone.ie ([213.233.128.44]:21273) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rs12N-0001S2-Nr for 10472@debbugs.gnu.org; Mon, 30 Jan 2012 18:53:29 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvcCAEksJ09tTEVT/2dsb2JhbAAMN61Vg3kBAQEDATIBRhALDQEKCRYPCQMCAQIBRQYNAQcBAYd4CbhciQ6BcQEEAgECAgkCAgEGBwQGAQsJgyUdAwwXBVICDCuDOQSbEoxZ Received: from unknown (HELO [192.168.1.79]) ([109.76.69.83]) by mail2.vodafone.ie with ESMTP; 30 Jan 2012 23:53:08 +0000 Message-ID: <4F272D64.5010004@draigBrady.com> Date: Mon, 30 Jan 2012 23:53:08 +0000 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 MIME-Version: 1.0 To: Eric Blake Subject: Re: bug#10472: `realpath --relative-to= /` outputs inconsistent trailing slash References: <201201101515.58406.vapier@gentoo.org> <4F270755.7080702@redhat.com> <4F271355.5060700@draigBrady.com> <4F27181E.9090705@redhat.com> In-Reply-To: <4F27181E.9090705@redhat.com> X-Enigmail-Version: 1.3.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 10472 Cc: Mike Frysinger , 10472@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On 01/30/2012 10:22 PM, Eric Blake wrote: > On 01/30/2012 03:01 PM, Pádraig Brady wrote: >>> $ realpath --relative-to=// //machine / // /bin >>> machine >>> / >>> . >>> /bin >>> >>> We need to make realpath robust to correct leading // handling; I don't >>> know if we should follow the lead of 'dirname' in only doing it on >>> machines where // is special, or if it is easier to make it honor POSIX >>> by special-casing // everywhere even on machines where / and // are >>> identical. >> >> So on such a machine, I guess `readlink -m //machine/` outputs '//machine'. > > Correct. > >> To match up with that, I think it makes sense to only do this on systems >> where a double slash is significant. > > I'm tending to agree - readlink, dirname, and realpath should all behave > consistently within a single compilation of coreutils. > >> >> BTW, this is how I'm interpreting this example: >> >>> $ realpath --relative-to=// //machine / // /bin >>> machine >>> / >>> . >>> /bin >> >> I'm taking --relative-to=// to mean relative to "the network". >> Hence relative output will be machines on the network, >> while absolute are local paths. > > Correct. > > Another bug still in the latest coreutils.git, but only on platforms > with distinct //: > > $ src/realpath / // /// > / > // > // > > Oops, that last line should be /. This bug is shared by readlink: > > $ src/readlink -m /// > // The above will require a gnulib fix >> gnulib says // matters for Apollo DomainOS (too old to port to), >> Cygwin, and z/OS. > > And I tested on Cygwin (if it wasn't obvious :) > > I can try to develop patches as part of porting coreutils 8.15 to cygwin I'll take you up on that, thanks! > (cygwin already has a realpath(1), but it is severely limited in that it > only takes one file name and no command line options on what to do with > that name; I'm pretty sure that the coreutils realpath is upwards > compatible with the existing cygwin realpath: > http://cygwin.com/ml/cygwin-apps/2012-01/msg00080.html). I had a look at the source, and it's just a simple wrapper around realpath(), that only accepts a single path. So coreutils realpath should be a drop in replacement. (wow it's hard to navigate cygwin stuff. It took me 3 mins to find the latest source). cheers, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 04 11:57:24 2012 Received: (at 10472) by debbugs.gnu.org; 4 Feb 2012 16:57:24 +0000 Received: from localhost ([127.0.0.1]:54461 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RtivT-0004Es-UP for submit@debbugs.gnu.org; Sat, 04 Feb 2012 11:57:24 -0500 Received: from qmta08.westchester.pa.mail.comcast.net ([76.96.62.80]:42578) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RtivR-0004Ee-91 for 10472@debbugs.gnu.org; Sat, 04 Feb 2012 11:57:23 -0500 Received: from omta16.westchester.pa.mail.comcast.net ([76.96.62.88]) by qmta08.westchester.pa.mail.comcast.net with comcast id Vsnh1i0031uE5Es58swd8a; Sat, 04 Feb 2012 16:56:37 +0000 Received: from office.redhat.com ([24.10.251.25]) by omta16.westchester.pa.mail.comcast.net with comcast id Vswa1i0090ZdyUg3cswcKx; Sat, 04 Feb 2012 16:56:37 +0000 From: Eric Blake To: bug-gnulib@gnu.org Subject: [PATCH] canonicalize: fix // handling Date: Sat, 4 Feb 2012 09:56:32 -0700 Message-Id: <1328374592-17072-1-git-send-email-eblake@redhat.com> X-Mailer: git-send-email 1.7.7.6 X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 10472 Cc: 10472@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On Cygwin, and other platforms where // is detected as distinct from / at configure time, the canonicalize routines were incorrectly treating all instances of multiple leading slashes as //. See also coreutils bug http://debbugs.gnu.org/10472 * lib/canonicalize.c (canonicalize_filename_mode): Don't convert /// to //, since only // is special. Signed-off-by: Eric Blake --- ChangeLog | 6 ++++++ lib/canonicalize.c | 12 +++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4bbe447..a9aa40a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-02-04 Eric Blake + + canonicalize: fix // handling + * lib/canonicalize.c (canonicalize_filename_mode): Don't convert + /// to //, since only // is special. + 2012-02-04 Bruno Haible ioctl: Fix test failure on native Windows. diff --git a/lib/canonicalize.c b/lib/canonicalize.c index d3e5645..ed094b7 100644 --- a/lib/canonicalize.c +++ b/lib/canonicalize.c @@ -145,7 +145,7 @@ canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode) rname_limit = rname + PATH_MAX; rname[0] = '/'; dest = rname + 1; - if (DOUBLE_SLASH_IS_DISTINCT_ROOT && name[1] == '/') + if (DOUBLE_SLASH_IS_DISTINCT_ROOT && name[1] == '/' && name[2] != '/') *dest++ = '/'; } @@ -169,7 +169,7 @@ canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode) if (dest > rname + 1) while ((--dest)[-1] != '/'); if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rname + 1 - && *dest == '/') + && *dest == '/' && dest[1] != '/') dest++; } else @@ -267,7 +267,8 @@ canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode) if (buf[0] == '/') { dest = rname + 1; /* It's an absolute symlink */ - if (DOUBLE_SLASH_IS_DISTINCT_ROOT && buf[1] == '/') + if (DOUBLE_SLASH_IS_DISTINCT_ROOT + && buf[1] == '/' && buf[2] != '/') *dest++ = '/'; } else @@ -277,7 +278,7 @@ canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode) if (dest > rname + 1) while ((--dest)[-1] != '/'); if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rname + 1 - && *dest == '/') + && *dest == '/' && dest[1] != '/') dest++; } @@ -295,7 +296,8 @@ canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode) } if (dest > rname + 1 && dest[-1] == '/') --dest; - if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rname + 1 && *dest == '/') + if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rname + 1 + && *dest == '/' && dest[1] != '/') dest++; *dest = '\0'; if (rname_limit != dest + 1) -- 1.7.7.6 From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 04 13:00:08 2012 Received: (at 10472) by debbugs.gnu.org; 4 Feb 2012 18:00:08 +0000 Received: from localhost ([127.0.0.1]:54505 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RtjuC-0005gr-9T for submit@debbugs.gnu.org; Sat, 04 Feb 2012 13:00:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:21107) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rtju8-0005gK-GX for 10472@debbugs.gnu.org; Sat, 04 Feb 2012 13:00:06 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q14HxNEK022456 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 4 Feb 2012 12:59:23 -0500 Received: from [10.3.113.45] (ovpn-113-45.phx2.redhat.com [10.3.113.45]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q14HxMnh002183; Sat, 4 Feb 2012 12:59:22 -0500 Message-ID: <4F2D71F9.1080802@redhat.com> Date: Sat, 04 Feb 2012 10:59:21 -0700 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20120131 Thunderbird/10.0 MIME-Version: 1.0 Subject: Re: bug#10472: [PATCH] canonicalize: fix // handling References: <201201101515.58406.vapier@gentoo.org> <1328374592-17072-1-git-send-email-eblake@redhat.com> In-Reply-To: <1328374592-17072-1-git-send-email-eblake@redhat.com> X-Enigmail-Version: 1.3.5 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigB5F5D1B804603D4082810510" X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-Spam-Score: -5.9 (-----) X-Debbugs-Envelope-To: 10472 Cc: bug-gnulib@gnu.org, 10472@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.9 (-----) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigB5F5D1B804603D4082810510 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 02/04/2012 09:56 AM, Eric Blake wrote: > On Cygwin, and other platforms where // is detected as distinct > from / at configure time, the canonicalize routines were incorrectly > treating all instances of multiple leading slashes as //. > See also coreutils bug http://debbugs.gnu.org/10472 >=20 > * lib/canonicalize.c (canonicalize_filename_mode): Don't convert > /// to //, since only // is special. >=20 > +++ b/lib/canonicalize.c > @@ -145,7 +145,7 @@ canonicalize_filename_mode (const char *name, canon= icalize_mode_t can_mode) > rname_limit =3D rname + PATH_MAX; > rname[0] =3D '/'; > dest =3D rname + 1; > - if (DOUBLE_SLASH_IS_DISTINCT_ROOT && name[1] =3D=3D '/') > + if (DOUBLE_SLASH_IS_DISTINCT_ROOT && name[1] =3D=3D '/' && name[= 2] !=3D '/') > *dest++ =3D '/'; This never initializes rname[1] if name is "///", > @@ -295,7 +296,8 @@ canonicalize_filename_mode (const char *name, canon= icalize_mode_t can_mode) > } > if (dest > rname + 1 && dest[-1] =3D=3D '/') > --dest; > - if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest =3D=3D rname + 1 && *dest = =3D=3D '/') > + if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest =3D=3D rname + 1 > + && *dest =3D=3D '/' && dest[1] !=3D '/') > dest++; which meant this was reading uninitialized memory, and depending on what was in the heap, might canonicalize "///" to "/" or "//". I'm pushing this additional fix to both files: diff --git i/lib/canonicalize-lgpl.c w/lib/canonicalize-lgpl.c index a61bef9..08e76fe 100644 --- i/lib/canonicalize-lgpl.c +++ w/lib/canonicalize-lgpl.c @@ -158,6 +158,7 @@ __realpath (const char *name, char *resolved) dest =3D rpath + 1; if (DOUBLE_SLASH_IS_DISTINCT_ROOT && name[1] =3D=3D '/' && name[2]= !=3D '/') *dest++ =3D '/'; + *dest =3D '\0'; } for (start =3D end =3D name; *start; start =3D end) diff --git i/lib/canonicalize.c w/lib/canonicalize.c index ed094b7..2c73094 100644 --- i/lib/canonicalize.c +++ w/lib/canonicalize.c @@ -147,6 +147,7 @@ canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode) dest =3D rname + 1; if (DOUBLE_SLASH_IS_DISTINCT_ROOT && name[1] =3D=3D '/' && name[2]= !=3D '/') *dest++ =3D '/'; + *dest =3D '\0'; } for (start =3D name; *start; start =3D end) --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enigB5F5D1B804603D4082810510 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJPLXH6AAoJEKeha0olJ0NqAIsH/Re0wF7wJDj47QZOx4jdIEag AD6LSazsDYimYLIo+JrNTnZWti3TslGMwFplI6hrOyBfpI36zpzl6M84yU3fSp5/ xDZVmgfZoeY0dNoxMTX50HH5k3xeZkiaUR0mZjVC2Hh+GdR6f9qHltMe2IoSDy6c SfjjdD3MYkIC50YZYkPsIishWSUNxQwht7mTjKPAn9EItP3kVupmJlHTgzoR9Xv8 nZovRRzxE7N5tgtDH1FDz6sQzlth+ge8twKl/HGxvbCBVss5fqDYNAKzmRWz2oHg 26KZMI8zVc/9SMCU6k4i6nNSjUN0q+Dwr3CGxBsvfl8NZinNo/R0ORMfawNRYAU= =+Go4 -----END PGP SIGNATURE----- --------------enigB5F5D1B804603D4082810510-- From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 04 13:39:40 2012 Received: (at 10472) by debbugs.gnu.org; 4 Feb 2012 18:39:40 +0000 Received: from localhost ([127.0.0.1]:54530 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RtkWR-0006qF-L6 for submit@debbugs.gnu.org; Sat, 04 Feb 2012 13:39:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:16160) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RtkWP-0006pz-41 for 10472@debbugs.gnu.org; Sat, 04 Feb 2012 13:39:39 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q14IcpOE001389 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 4 Feb 2012 13:38:51 -0500 Received: from [10.3.113.24] (ovpn-113-24.phx2.redhat.com [10.3.113.24]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q14IcoXf013516; Sat, 4 Feb 2012 13:38:50 -0500 Message-ID: <4F2D7B34.9000005@redhat.com> Date: Sat, 04 Feb 2012 11:38:44 -0700 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20120131 Thunderbird/10.0 MIME-Version: 1.0 Subject: Re: bug#10472: [PATCH] canonicalize: fix // handling References: <201201101515.58406.vapier@gentoo.org> <1328374592-17072-1-git-send-email-eblake@redhat.com> <4F2D71F9.1080802@redhat.com> In-Reply-To: <4F2D71F9.1080802@redhat.com> X-Enigmail-Version: 1.3.5 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigC5B34B94DCEEF0756386529A" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Spam-Score: -5.9 (-----) X-Debbugs-Envelope-To: 10472 Cc: bug-gnulib@gnu.org, 10472@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.9 (-----) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigC5B34B94DCEEF0756386529A Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 02/04/2012 10:59 AM, Eric Blake wrote: > On 02/04/2012 09:56 AM, Eric Blake wrote: >> On Cygwin, and other platforms where // is detected as distinct >> from / at configure time, the canonicalize routines were incorrectly >> treating all instances of multiple leading slashes as //. >> See also coreutils bug http://debbugs.gnu.org/10472 >> >> * lib/canonicalize.c (canonicalize_filename_mode): Don't convert >> /// to //, since only // is special. >> >=20 > which meant this was reading uninitialized memory, and depending on wha= t > was in the heap, might canonicalize "///" to "/" or "//". I'm pushing > this additional fix to both files: >=20 > diff --git i/lib/canonicalize-lgpl.c w/lib/canonicalize-lgpl.c > index a61bef9..08e76fe 100644 > --- i/lib/canonicalize-lgpl.c > +++ w/lib/canonicalize-lgpl.c > @@ -158,6 +158,7 @@ __realpath (const char *name, char *resolved) > dest =3D rpath + 1; > if (DOUBLE_SLASH_IS_DISTINCT_ROOT && name[1] =3D=3D '/' && name[= 2] !=3D > '/') > *dest++ =3D '/'; > + *dest =3D '\0'; > } Still not right. If you have a symlink at //some/path whose contents is /, then that would canonicalize to '//' without triggering any valgrind complaints, because I missed the code that resets rpath on encountering absolute symlink contents. Meanwhile, pre-assigning *dest is a pessimization on platforms where // and / are identical. I'm pushing this instead. =46rom d1f3998942236194f1894c45804ec947d07ed134 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Sat, 4 Feb 2012 11:11:40 -0700 Subject: [PATCH] canonicalize: avoid uninitialized memory use When DOUBLE_SLASH_IS_DISTINCT_ROOT is non-zero, then we were reading the contents of rpath[1] even when we had never written anything there, which meant that "///" would usually canonicalize to "/" but sometimes to "//" if a '/' was leftover in the heap. This condition could also occur via 'ln -s / //some/path' and canonicalizing //some/path, where we rewind rpath but do not clear out the previous round. Platforms where "//" and "/" are equivalent do not suffer from this read-beyond-written bounds. * lib/canonicalize-lgpl.c (__realpath): Avoid possibility of random '/' left in dest. * lib/canonicalize.c (canonicalize_filename_mode): Likewise. Signed-off-by: Eric Blake --- ChangeLog | 7 +++++++ lib/canonicalize-lgpl.c | 17 ++++++++++++----- lib/canonicalize.c | 17 ++++++++++++----- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8f08543..aeea7c8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2012-02-04 Eric Blake + + canonicalize: avoid uninitialized memory use + * lib/canonicalize-lgpl.c (__realpath): Avoid possibility of + random '/' left in dest. + * lib/canonicalize.c (canonicalize_filename_mode): Likewise. + 2012-02-04 Bruno Haible spawn-pipe tests: Fix a NULL program name in a diagnostic. diff --git a/lib/canonicalize-lgpl.c b/lib/canonicalize-lgpl.c index a61bef9..7aa2d92 100644 --- a/lib/canonicalize-lgpl.c +++ b/lib/canonicalize-lgpl.c @@ -156,8 +156,12 @@ __realpath (const char *name, char *resolved) { rpath[0] =3D '/'; dest =3D rpath + 1; - if (DOUBLE_SLASH_IS_DISTINCT_ROOT && name[1] =3D=3D '/' && name[2]= !=3D '/') - *dest++ =3D '/'; + if (DOUBLE_SLASH_IS_DISTINCT_ROOT) + { + if (name[1] =3D=3D '/' && name[2] !=3D '/') + *dest++ =3D '/'; + *dest =3D '\0'; + } } for (start =3D end =3D name; *start; start =3D end) @@ -298,9 +302,12 @@ __realpath (const char *name, char *resolved) if (buf[0] =3D=3D '/') { dest =3D rpath + 1; /* It's an absolute symlink */= - if (DOUBLE_SLASH_IS_DISTINCT_ROOT - && buf[1] =3D=3D '/' && buf[2] !=3D '/') - *dest++ =3D '/'; + if (DOUBLE_SLASH_IS_DISTINCT_ROOT) + { + if (buf[1] =3D=3D '/' && buf[2] !=3D '/') + *dest++ =3D '/'; + *dest =3D '\0'; + } } else { diff --git a/lib/canonicalize.c b/lib/canonicalize.c index ed094b7..583c1a4 100644 --- a/lib/canonicalize.c +++ b/lib/canonicalize.c @@ -145,8 +145,12 @@ canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode) rname_limit =3D rname + PATH_MAX; rname[0] =3D '/'; dest =3D rname + 1; - if (DOUBLE_SLASH_IS_DISTINCT_ROOT && name[1] =3D=3D '/' && name[2]= !=3D '/') - *dest++ =3D '/'; + if (DOUBLE_SLASH_IS_DISTINCT_ROOT) + { + if (name[1] =3D=3D '/' && name[2] !=3D '/') + *dest++ =3D '/'; + *dest =3D '\0'; + } } for (start =3D name; *start; start =3D end) @@ -267,9 +271,12 @@ canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode) if (buf[0] =3D=3D '/') { dest =3D rname + 1; /* It's an absolute symlink */= - if (DOUBLE_SLASH_IS_DISTINCT_ROOT - && buf[1] =3D=3D '/' && buf[2] !=3D '/') - *dest++ =3D '/'; + if (DOUBLE_SLASH_IS_DISTINCT_ROOT) + { + if (buf[1] =3D=3D '/' && buf[2] !=3D '/') + *dest++ =3D '/'; + *dest =3D '\0'; + } } else { --=20 1.7.7.6 --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enigC5B34B94DCEEF0756386529A Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJPLXs6AAoJEKeha0olJ0Nq/MUH/1UrrX18EQuqlhfVt85NElpz WaBaC4yRNBi5I0wRHd6KUC47jfRlmzy6pF82tOgvaWBy+kXyEb91x2ggljJ6dW6t EKjfNHTix7Uead11Cg3IC957QORKhnoC12URlbsGUzDNYWnf7bKk8OClPqw9MxTN m/v7mPUoQSD8YB8N6i7e9JXMecQBXSsbKMaDEErLUzGQMwHNBVP/zeZiJD3tAYK/ F2OFOaxaLqze+6GSpgTXJXjm5L9xOkX4blrOIH/8qhHhsSmhxY5y0mhQpZ+SAhdP ZbBOPvW/qnU0S58BfVMdP9lEhZrbm4T/7kohSvUrwXFP+KESH3P/n3/cVVnMluY= =i4nj -----END PGP SIGNATURE----- --------------enigC5B34B94DCEEF0756386529A-- From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 04 14:06:51 2012 Received: (at 10472) by debbugs.gnu.org; 4 Feb 2012 19:06:51 +0000 Received: from localhost ([127.0.0.1]:54562 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rtkwk-0008FA-Iv for submit@debbugs.gnu.org; Sat, 04 Feb 2012 14:06:51 -0500 Received: from qmta04.westchester.pa.mail.comcast.net ([76.96.62.40]:47685) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rtkwg-0008Ew-1z for 10472@debbugs.gnu.org; Sat, 04 Feb 2012 14:06:48 -0500 Received: from omta20.westchester.pa.mail.comcast.net ([76.96.62.71]) by qmta04.westchester.pa.mail.comcast.net with comcast id Vv5A1i0021YDfWL54v61tf; Sat, 04 Feb 2012 19:06:01 +0000 Received: from office.redhat.com ([24.10.251.25]) by omta20.westchester.pa.mail.comcast.net with comcast id Vv5x1i0180ZdyUg3gv61tN; Sat, 04 Feb 2012 19:06:01 +0000 From: Eric Blake To: 10472@debbugs.gnu.org Subject: [PATCH] realpath: fix problems with // handling Date: Sat, 4 Feb 2012 12:05:56 -0700 Message-Id: <1328382356-9521-1-git-send-email-eblake@redhat.com> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <4F272D64.5010004@draigBrady.com> References: <4F272D64.5010004@draigBrady.com> X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 10472 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On platforms like Cygwin where / and // are distinct, realpath was incorrectly collapsing // into /. http://debbugs.gnu.org/10472. * src/realpath.c (path_common_prefix): When // is special, treat / and // as having no common match. (relpath): Allow for no match even without --relative-base. --- This is the coreutils side of the patch; for this to work, we also have to upgrade to the latest gnulib. I'm not pushing this until we decide what to do about testing; I guess we've already figured out how to make basename and dirname tests conditional on whether they are on Linux or Cygwin (that is, whether // and / are the same or different), so I should do something similar to that for the realpath test. But I can at least get a code review on realpath.c while figuring out the testing situation. src/realpath.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/src/realpath.c b/src/realpath.c index 2dc5e11..f06fbcc 100644 --- a/src/realpath.c +++ b/src/realpath.c @@ -131,6 +131,10 @@ path_common_prefix (const char *path1, const char *path2) int i = 0; int ret = 0; + if (DOUBLE_SLASH_IS_DISTINCT_ROOT && *path1 == '/' && *path2 == '/' + && (path1[1] == '/') != (path2[1] == '/')) + return 0; + while (*path1 && *path2) { if (*path1 != *path2) @@ -168,6 +172,9 @@ relpath (const char *can_fname) /* Skip the prefix common to --relative-to and path. */ int common_index = path_common_prefix (can_relative_to, can_fname); + if (!common_index) + return false; + const char *relto_suffix = can_relative_to + common_index; const char *fname_suffix = can_fname + common_index; -- 1.7.7.6 From debbugs-submit-bounces@debbugs.gnu.org Wed Feb 08 05:14:18 2012 Received: (at 10472) by debbugs.gnu.org; 8 Feb 2012 10:14:18 +0000 Received: from localhost ([127.0.0.1]:60046 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rv4XZ-0004Js-Tk for submit@debbugs.gnu.org; Wed, 08 Feb 2012 05:14:18 -0500 Received: from mail3.vodafone.ie ([213.233.128.45]:7704) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Rv4XX-0004Jc-IU for 10472@debbugs.gnu.org; Wed, 08 Feb 2012 05:14:17 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApMBAGhJMk9tTc6T/2dsb2JhbAAMN4UNrU4BAQEEAQIgDwFGEAsNAQMDAQIBAgIFFgsCAgkDAgECARYnCAYNAQUCAQGIAacrkgyBL4oOAQUBAQECAQUCAgIIAQEEDQQGAQsJgyUdAwwXBVICDCoBAQGCIoEWBJMEiCKFFYdO Received: from unknown (HELO [192.168.1.79]) ([109.77.206.147]) by mail3.vodafone.ie with ESMTP; 08 Feb 2012 10:13:04 +0000 Message-ID: <4F324AAD.4040708@draigBrady.com> Date: Wed, 08 Feb 2012 10:13:01 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 MIME-Version: 1.0 To: Eric Blake Subject: Re: bug#10472: [PATCH] canonicalize: fix // handling References: <201201101515.58406.vapier@gentoo.org> <1328374592-17072-1-git-send-email-eblake@redhat.com> <4F2D71F9.1080802@redhat.com> <4F2D7B34.9000005@redhat.com> In-Reply-To: <4F2D7B34.9000005@redhat.com> X-Enigmail-Version: 1.3.2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 10472 Cc: bug-gnulib@gnu.org, 10472@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On 02/04/2012 06:38 PM, Eric Blake wrote: > On 02/04/2012 10:59 AM, Eric Blake wrote: >> On 02/04/2012 09:56 AM, Eric Blake wrote: >>> On Cygwin, and other platforms where // is detected as distinct >>> from / at configure time, the canonicalize routines were incorrectly >>> treating all instances of multiple leading slashes as //. >>> See also coreutils bug http://debbugs.gnu.org/10472 >>> >>> * lib/canonicalize.c (canonicalize_filename_mode): Don't convert >>> /// to //, since only // is special. >>> > >> >> which meant this was reading uninitialized memory, and depending on what >> was in the heap, might canonicalize "///" to "/" or "//". I'm pushing >> this additional fix to both files: >> >> diff --git i/lib/canonicalize-lgpl.c w/lib/canonicalize-lgpl.c >> index a61bef9..08e76fe 100644 >> --- i/lib/canonicalize-lgpl.c >> +++ w/lib/canonicalize-lgpl.c >> @@ -158,6 +158,7 @@ __realpath (const char *name, char *resolved) >> dest = rpath + 1; >> if (DOUBLE_SLASH_IS_DISTINCT_ROOT && name[1] == '/' && name[2] != >> '/') >> *dest++ = '/'; >> + *dest = '\0'; >> } > > Still not right. If you have a symlink at //some/path whose contents is > /, then that would canonicalize to '//' without triggering any valgrind > complaints, because I missed the code that resets rpath on encountering > absolute symlink contents. Meanwhile, pre-assigning *dest is a > pessimization on platforms where // and / are identical. I'm pushing > this instead. > > From d1f3998942236194f1894c45804ec947d07ed134 Mon Sep 17 00:00:00 2001 > From: Eric Blake > Date: Sat, 4 Feb 2012 11:11:40 -0700 > Subject: [PATCH] canonicalize: avoid uninitialized memory use > > When DOUBLE_SLASH_IS_DISTINCT_ROOT is non-zero, then we were > reading the contents of rpath[1] even when we had never written > anything there, which meant that "///" would usually canonicalize > to "/" but sometimes to "//" if a '/' was leftover in the heap. > This condition could also occur via 'ln -s / //some/path' and > canonicalizing //some/path, where we rewind rpath but do not > clear out the previous round. Platforms where "//" and "/" are > equivalent do not suffer from this read-beyond-written bounds. > > * lib/canonicalize-lgpl.c (__realpath): Avoid possibility of > random '/' left in dest. > * lib/canonicalize.c (canonicalize_filename_mode): Likewise. > > Signed-off-by: Eric Blake > --- > ChangeLog | 7 +++++++ > lib/canonicalize-lgpl.c | 17 ++++++++++++----- > lib/canonicalize.c | 17 ++++++++++++----- > 3 files changed, 31 insertions(+), 10 deletions(-) > > diff --git a/ChangeLog b/ChangeLog > index 8f08543..aeea7c8 100644 > --- a/ChangeLog > +++ b/ChangeLog > @@ -1,3 +1,10 @@ > +2012-02-04 Eric Blake > + > + canonicalize: avoid uninitialized memory use > + * lib/canonicalize-lgpl.c (__realpath): Avoid possibility of > + random '/' left in dest. > + * lib/canonicalize.c (canonicalize_filename_mode): Likewise. > + > 2012-02-04 Bruno Haible > > spawn-pipe tests: Fix a NULL program name in a diagnostic. > diff --git a/lib/canonicalize-lgpl.c b/lib/canonicalize-lgpl.c > index a61bef9..7aa2d92 100644 > --- a/lib/canonicalize-lgpl.c > +++ b/lib/canonicalize-lgpl.c > @@ -156,8 +156,12 @@ __realpath (const char *name, char *resolved) > { > rpath[0] = '/'; > dest = rpath + 1; > - if (DOUBLE_SLASH_IS_DISTINCT_ROOT && name[1] == '/' && name[2] != > '/') > - *dest++ = '/'; > + if (DOUBLE_SLASH_IS_DISTINCT_ROOT) > + { > + if (name[1] == '/' && name[2] != '/') > + *dest++ = '/'; > + *dest = '\0'; > + } > } > > for (start = end = name; *start; start = end) > @@ -298,9 +302,12 @@ __realpath (const char *name, char *resolved) > if (buf[0] == '/') > { > dest = rpath + 1; /* It's an absolute symlink */ > - if (DOUBLE_SLASH_IS_DISTINCT_ROOT > - && buf[1] == '/' && buf[2] != '/') > - *dest++ = '/'; > + if (DOUBLE_SLASH_IS_DISTINCT_ROOT) > + { > + if (buf[1] == '/' && buf[2] != '/') > + *dest++ = '/'; > + *dest = '\0'; > + } > } > else > { > diff --git a/lib/canonicalize.c b/lib/canonicalize.c > index ed094b7..583c1a4 100644 > --- a/lib/canonicalize.c > +++ b/lib/canonicalize.c > @@ -145,8 +145,12 @@ canonicalize_filename_mode (const char *name, > canonicalize_mode_t can_mode) > rname_limit = rname + PATH_MAX; > rname[0] = '/'; > dest = rname + 1; > - if (DOUBLE_SLASH_IS_DISTINCT_ROOT && name[1] == '/' && name[2] != > '/') > - *dest++ = '/'; > + if (DOUBLE_SLASH_IS_DISTINCT_ROOT) > + { > + if (name[1] == '/' && name[2] != '/') > + *dest++ = '/'; > + *dest = '\0'; > + } > } > > for (start = name; *start; start = end) > @@ -267,9 +271,12 @@ canonicalize_filename_mode (const char *name, > canonicalize_mode_t can_mode) > if (buf[0] == '/') > { > dest = rname + 1; /* It's an absolute symlink */ > - if (DOUBLE_SLASH_IS_DISTINCT_ROOT > - && buf[1] == '/' && buf[2] != '/') > - *dest++ = '/'; > + if (DOUBLE_SLASH_IS_DISTINCT_ROOT) > + { > + if (buf[1] == '/' && buf[2] != '/') > + *dest++ = '/'; > + *dest = '\0'; > + } > } > else > { Thanks for handling this Eric. I was wondering if you had seen this and what overlap there is? http://lists.gnu.org/archive/html/bug-gnulib/2012-01/msg00253.html cheers, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Wed Feb 08 11:20:18 2012 Received: (at 10472) by debbugs.gnu.org; 8 Feb 2012 16:20:18 +0000 Received: from localhost ([127.0.0.1]:60802 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RvAFm-0005Iv-7O for submit@debbugs.gnu.org; Wed, 08 Feb 2012 11:20:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58784) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RvAFj-0005Ih-Cj for 10472@debbugs.gnu.org; Wed, 08 Feb 2012 11:20:17 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q18GJ8QY001174 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 8 Feb 2012 11:19:09 -0500 Received: from [10.3.113.116] (ovpn-113-116.phx2.redhat.com [10.3.113.116]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q18GJ8Bi001408; Wed, 8 Feb 2012 11:19:08 -0500 Message-ID: <4F32A07B.8000200@redhat.com> Date: Wed, 08 Feb 2012 09:19:07 -0700 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20120131 Thunderbird/10.0 MIME-Version: 1.0 To: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= Subject: Re: bug#10472: [PATCH] canonicalize: fix // handling References: <201201101515.58406.vapier@gentoo.org> <1328374592-17072-1-git-send-email-eblake@redhat.com> <4F2D71F9.1080802@redhat.com> <4F2D7B34.9000005@redhat.com> <4F324AAD.4040708@draigBrady.com> In-Reply-To: <4F324AAD.4040708@draigBrady.com> X-Enigmail-Version: 1.3.5 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigAED4E36B7883997ECDC34968" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Spam-Score: -6.9 (------) X-Debbugs-Envelope-To: 10472 Cc: bug-gnulib@gnu.org, 10472@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigAED4E36B7883997ECDC34968 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 02/08/2012 03:13 AM, P=C3=A1draig Brady wrote: >> From d1f3998942236194f1894c45804ec947d07ed134 Mon Sep 17 00:00:00 2001= >> From: Eric Blake >> Date: Sat, 4 Feb 2012 11:11:40 -0700 >> Subject: [PATCH] canonicalize: avoid uninitialized memory use >> >> When DOUBLE_SLASH_IS_DISTINCT_ROOT is non-zero, then we were >> reading the contents of rpath[1] even when we had never written >> anything there, which meant that "///" would usually canonicalize >> to "/" but sometimes to "//" if a '/' was leftover in the heap. >> This condition could also occur via 'ln -s / //some/path' and >> canonicalizing //some/path, where we rewind rpath but do not >> clear out the previous round. Platforms where "//" and "/" are >> equivalent do not suffer from this read-beyond-written bounds. >> >=20 > Thanks for handling this Eric. No problem. > I was wondering if you had seen this and what overlap there is? > http://lists.gnu.org/archive/html/bug-gnulib/2012-01/msg00253.html I saw it go by, but never looked at it closely. I guess it's time to revive that thread, although it may need rebasing now. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enigAED4E36B7883997ECDC34968 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJPMqB8AAoJEKeha0olJ0NqvHMH/2uVg7WM7MOCiRtxCeXZfhUW oBQf7G1Zo5nmNZcy98ab9f9iEe/oacB/0/uinX8Rs4nsSDoGUn9SfVwbkyvVU0Wb gg2jO3YXCU/sIBJTUSYZJUODyOOIHPVrmusTl6PYJcdcSrxPHJuyYO6U2dJXHG/9 1leEdPTfICh5RdkNFCeXd/5o+bgC5vvc628oxCnKa5wxVwmfcn+ccJFoEI6fQmVy ar3SzpcbI+7kvP1aoOok1wBR25slwZgVXiBUimF5jTRnM23HBuCs7+zz8adI9vI+ 2wFpH1zyTvrZwa+YXimg9pCB3rF/7nfXBxSYmRSb5rVq2mO+LhIaFNjQJzuX57M= =TpgX -----END PGP SIGNATURE----- --------------enigAED4E36B7883997ECDC34968-- From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 20 10:23:57 2012 Received: (at 10472) by debbugs.gnu.org; 20 Feb 2012 15:23:57 +0000 Received: from localhost ([127.0.0.1]:47562 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RzV5l-0001i3-9f for submit@debbugs.gnu.org; Mon, 20 Feb 2012 10:23:57 -0500 Received: from mail3.vodafone.ie ([213.233.128.45]:45902) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RzV5e-0001hl-L7 for 10472@debbugs.gnu.org; Mon, 20 Feb 2012 10:23:51 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApMBAGxkQk9tTDS1/2dsb2JhbAAMOLRNAQEBBDIBRhALDQEKCRYPCQMCAQIBRQYNAQcBAcIVjC8JBgIDBgMHAgkBDwKEFINEBJs2hRuHUw Received: from unknown (HELO [192.168.1.79]) ([109.76.52.181]) by mail3.vodafone.ie with ESMTP; 20 Feb 2012 15:21:29 +0000 Message-ID: <4F4264F8.3000608@draigBrady.com> Date: Mon, 20 Feb 2012 15:21:28 +0000 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 MIME-Version: 1.0 To: Eric Blake Subject: Re: bug#10472: [PATCH] realpath: fix problems with // handling References: <4F272D64.5010004@draigBrady.com> <1328382356-9521-1-git-send-email-eblake@redhat.com> In-Reply-To: <1328382356-9521-1-git-send-email-eblake@redhat.com> X-Enigmail-Version: 1.3.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 10472 Cc: 10472@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On 02/04/2012 07:05 PM, Eric Blake wrote: > On platforms like Cygwin where / and // are distinct, realpath was > incorrectly collapsing // into /. http://debbugs.gnu.org/10472. > > * src/realpath.c (path_common_prefix): When // is special, treat / > and // as having no common match. > (relpath): Allow for no match even without --relative-base. > --- > > This is the coreutils side of the patch; for this to work, we also > have to upgrade to the latest gnulib. > > I'm not pushing this until we decide what to do about testing; I > guess we've already figured out how to make basename and dirname > tests conditional on whether they are on Linux or Cygwin (that is, > whether // and / are the same or different), so I should do something > similar to that for the realpath test. But I can at least get a > code review on realpath.c while figuring out the testing situation. > > src/realpath.c | 7 +++++++ > 1 files changed, 7 insertions(+), 0 deletions(-) > > diff --git a/src/realpath.c b/src/realpath.c > index 2dc5e11..f06fbcc 100644 > --- a/src/realpath.c > +++ b/src/realpath.c > @@ -131,6 +131,10 @@ path_common_prefix (const char *path1, const char *path2) > int i = 0; > int ret = 0; > > + if (DOUBLE_SLASH_IS_DISTINCT_ROOT && *path1 == '/' && *path2 == '/' > + && (path1[1] == '/') != (path2[1] == '/')) > + return 0; > + > while (*path1 && *path2) > { > if (*path1 != *path2) > @@ -168,6 +172,9 @@ relpath (const char *can_fname) > > /* Skip the prefix common to --relative-to and path. */ > int common_index = path_common_prefix (can_relative_to, can_fname); > + if (!common_index) > + return false; > + > const char *relto_suffix = can_relative_to + common_index; > const char *fname_suffix = can_fname + common_index; > is the DOUBLE_SLASH_IS_DISTINCT_ROOT check needed in realpath.c I.E. if we get a leading // then that define is implicit? Also doesn't path_prefix() need the same adjustment, so as to verify --relative-base in the same way? cheers, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 13 23:45:23 2012 Received: (at 10472) by debbugs.gnu.org; 14 Mar 2012 03:45:23 +0000 Received: from localhost ([127.0.0.1]:49676 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S7f9O-0001QS-9C for submit@debbugs.gnu.org; Tue, 13 Mar 2012 23:45:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1470) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S7f9K-0001QD-SR for 10472@debbugs.gnu.org; Tue, 13 Mar 2012 23:45:21 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q2E3FHOI020234 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 13 Mar 2012 23:15:17 -0400 Received: from [10.3.113.33] (ovpn-113-33.phx2.redhat.com [10.3.113.33]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q2E3FGBh009085; Tue, 13 Mar 2012 23:15:17 -0400 Message-ID: <4F600D44.6070603@redhat.com> Date: Tue, 13 Mar 2012 21:15:16 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20120216 Thunderbird/10.0.1 MIME-Version: 1.0 To: =?ISO-8859-1?Q?P=E1draig_Brady?= Subject: Re: bug#10472: [PATCH] realpath: fix problems with // handling References: <4F272D64.5010004@draigBrady.com> <1328382356-9521-1-git-send-email-eblake@redhat.com> <4F4264F8.3000608@draigBrady.com> In-Reply-To: <4F4264F8.3000608@draigBrady.com> X-Enigmail-Version: 1.3.5 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig0FB1A40B3825D041C0EA1087" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-Spam-Score: -6.9 (------) X-Debbugs-Envelope-To: 10472 Cc: 10472@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig0FB1A40B3825D041C0EA1087 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 02/20/2012 08:21 AM, P=E1draig Brady wrote: > On 02/04/2012 07:05 PM, Eric Blake wrote: >> On platforms like Cygwin where / and // are distinct, realpath was >> incorrectly collapsing // into /. http://debbugs.gnu.org/10472. >> >> This is the coreutils side of the patch; for this to work, we also >> have to upgrade to the latest gnulib. The gnulib update has happened in the meantime. >> >> I'm not pushing this until we decide what to do about testing; I >> guess we've already figured out how to make basename and dirname >> tests conditional on whether they are on Linux or Cygwin (that is, >> whether // and / are the same or different), so I should do something >> similar to that for the realpath test. But I can at least get a >> code review on realpath.c while figuring out the testing situation. I'm planning on resubmitting this series soon, once I polish my test, with hopes of inclusion in this week's release. >> +++ b/src/realpath.c >> @@ -131,6 +131,10 @@ path_common_prefix (const char *path1, const char= *path2) >> int i =3D 0; >> int ret =3D 0; >> >> + if (DOUBLE_SLASH_IS_DISTINCT_ROOT && *path1 =3D=3D '/' && *path2 =3D= =3D '/' >> + && (path1[1] =3D=3D '/') !=3D (path2[1] =3D=3D '/')) >> + return 0; >> + >> while (*path1 && *path2) >> { >> if (*path1 !=3D *path2) > is the DOUBLE_SLASH_IS_DISTINCT_ROOT check needed in realpath.c > I.E. if we get a leading // then that define is implicit? Good point - path_common_prefix is only ever called with canonical names, which means that it will only ever encounter // on systems where it matters. >=20 > Also doesn't path_prefix() need the same adjustment, > so as to verify --relative-base in the same way? Yes, it looks like it. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig0FB1A40B3825D041C0EA1087 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJPYA1EAAoJEKeha0olJ0Nq7/kH/3Y6HFJ0fUSjrCxSDuYPKx44 lwRyb2EMtNAKOisk7gO3MYNUuDAWIr8Nkm6yrwGz0qZLpJNaGJoahLcLhACEtUEe VQ/+dL+bhsSDEtlA5tPw4mmtybX51Z+P+IzVX3xgR8pw/1SsgV5mro7bNSQZJ+5v TREW9fWFIVjNemCN95KimOiYsZoiOJOi9nd3OA+4tGpoDtp9w9uCG+ASl3kTn509 AXwJMeXkmOjyess+k3jqTaNjuQH5j70nDF8nJQ02IvF3ECDkUAYzvalr5ehtov9Q UR0X+FpH/g3vs6k5C/uYmsHKApNAHfS8UINySY+7trdxNTRCXGDYfSnr5oOuzck= =Qspg -----END PGP SIGNATURE----- --------------enig0FB1A40B3825D041C0EA1087-- From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 14 00:37:58 2012 Received: (at 10472) by debbugs.gnu.org; 14 Mar 2012 04:37:58 +0000 Received: from localhost ([127.0.0.1]:49734 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S7fyG-0002b9-UW for submit@debbugs.gnu.org; Wed, 14 Mar 2012 00:37:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45616) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S7fy3-0002ap-F9 for 10472@debbugs.gnu.org; Wed, 14 Mar 2012 00:37:55 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q2E47gk0009660 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 14 Mar 2012 00:07:42 -0400 Received: from [10.3.113.33] (ovpn-113-33.phx2.redhat.com [10.3.113.33]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q2E47gUu003713; Wed, 14 Mar 2012 00:07:42 -0400 Message-ID: <4F60198D.90809@redhat.com> Date: Tue, 13 Mar 2012 22:07:41 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20120216 Thunderbird/10.0.1 MIME-Version: 1.0 Subject: Re: bug#10472: [PATCH] realpath: fix problems with // handling References: <4F272D64.5010004@draigBrady.com> <1328382356-9521-1-git-send-email-eblake@redhat.com> <4F4264F8.3000608@draigBrady.com> <4F600D44.6070603@redhat.com> In-Reply-To: <4F600D44.6070603@redhat.com> X-Enigmail-Version: 1.3.5 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig401D71A2CC47401B8947EC62" X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Spam-Score: -5.9 (-----) X-Debbugs-Envelope-To: 10472 Cc: =?ISO-8859-1?Q?P=E1draig_Brady?= , 10472@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.9 (-----) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig401D71A2CC47401B8947EC62 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 03/13/2012 09:15 PM, Eric Blake wrote: >> Also doesn't path_prefix() need the same adjustment, >> so as to verify --relative-base in the same way? >=20 > Yes, it looks like it. In fact, I found another bug, this time present also on Linux: $ realpath --relative-base=3D/ --relative-to=3D/ / / when it should really output '.' (since '/' relative to itself is '.', and ALL files are below '/' [except when '//' is special]). Likewise: $ realpath --relative-base=3D/usr/local --relative-to=3D/usr \ /usr /usr/local/lib /usr /usr/local/lib when it should really output '/usr' (absolute, since it is not a child of /usr/local) and 'local/lib' (which is a file below /usr/local, and an output name relative to /usr). My test caught these, so now I have to revisit my realpath.c patch. It's getting too late tonight, so I'll have to post the series early tomorrow. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig401D71A2CC47401B8947EC62 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJPYBmNAAoJEKeha0olJ0NqoSkH/2x+pXj8hTpsAGL9Sc1he+BP uMp0jKIiUvS2lSs05iukJ+RLUyvF7pZ74yL1/UCq0QclLYnXXI8orAfba02AkE90 5kWVeOeKu3/05aK0dDJMvXTfsT/9BGRQ84W+2/ltyfAh7b58HRuOXI36/XWNsWEU 8LdsPObcx8vVSoqQp9m3ztzWTSDdg8OApUTFD7sAILyuBnAmAXfJnSTayY4nPfeG uOGPf1b9m/wO2X5v2WEgoXO05DCJljjnxx555qBFvUx9trQEgD3syr/+oG3z8Sat Dx9ZhXtDek4xN9evB4eCtUShDi6E3IS9Q1TtU6JZ1X92f9LeCRvWy9hknH5vYFY= =SLIz -----END PGP SIGNATURE----- --------------enig401D71A2CC47401B8947EC62-- From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 14 05:43:03 2012 Received: (at 10472) by debbugs.gnu.org; 14 Mar 2012 09:43:03 +0000 Received: from localhost ([127.0.0.1]:50003 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S7kjX-0001Eo-FT for submit@debbugs.gnu.org; Wed, 14 Mar 2012 05:43:03 -0400 Received: from mail3.vodafone.ie ([213.233.128.45]:9723) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S7kjU-0001EM-IE for 10472@debbugs.gnu.org; Wed, 14 Mar 2012 05:43:01 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkgDAJxgYE9tTG0N/2dsb2JhbAAMN7MPgXsDhBsBAQEDATIBRhALDQEKCRYPCQMCAQIBRQYNAQcBAYgBvEmLOYU/BJtjihmCZg Received: from unknown (HELO [192.168.1.79]) ([109.76.109.13]) by mail3.vodafone.ie with ESMTP; 14 Mar 2012 09:12:58 +0000 Message-ID: <4F606119.7090406@draigBrady.com> Date: Wed, 14 Mar 2012 09:12:57 +0000 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 MIME-Version: 1.0 To: Eric Blake Subject: Re: bug#10472: [PATCH] realpath: fix problems with // handling References: <4F272D64.5010004@draigBrady.com> <1328382356-9521-1-git-send-email-eblake@redhat.com> <4F4264F8.3000608@draigBrady.com> <4F600D44.6070603@redhat.com> <4F60198D.90809@redhat.com> In-Reply-To: <4F60198D.90809@redhat.com> X-Enigmail-Version: 1.3.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 10472 Cc: 10472@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On 03/14/2012 04:07 AM, Eric Blake wrote: > On 03/13/2012 09:15 PM, Eric Blake wrote: >>> Also doesn't path_prefix() need the same adjustment, >>> so as to verify --relative-base in the same way? >> >> Yes, it looks like it. > > In fact, I found another bug, this time present also on Linux: > > $ realpath --relative-base=/ --relative-to=/ / > / This may be a local issue? $ src/realpath --relative-base=/ --relative-to=/ / . > > when it should really output '.' (since '/' relative to itself is '.', > and ALL files are below '/' [except when '//' is special]). Likewise: > > $ realpath --relative-base=/usr/local --relative-to=/usr \ > /usr /usr/local/lib > /usr > /usr/local/lib > > when it should really output '/usr' (absolute, since it is not a child > of /usr/local) and 'local/lib' (which is a file below /usr/local, and an > output name relative to /usr). Well that was by design. I.E. --relative-base is a guard, which if either --relative-to or the specified paths go higher, an absolute name will be output. cheers, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 14 06:23:47 2012 Received: (at 10472) by debbugs.gnu.org; 14 Mar 2012 10:23:47 +0000 Received: from localhost ([127.0.0.1]:50066 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S7lMv-0002AO-Iy for submit@debbugs.gnu.org; Wed, 14 Mar 2012 06:23:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8496) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S7lMr-0002AE-41 for 10472@debbugs.gnu.org; Wed, 14 Mar 2012 06:23:44 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q2E9rcdD023814 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 14 Mar 2012 05:53:38 -0400 Received: from [10.3.113.33] (ovpn-113-33.phx2.redhat.com [10.3.113.33]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q2E9raaS030047; Wed, 14 Mar 2012 05:53:38 -0400 Message-ID: <4F606A9F.7000403@redhat.com> Date: Wed, 14 Mar 2012 03:53:35 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20120216 Thunderbird/10.0.1 MIME-Version: 1.0 To: =?ISO-8859-1?Q?P=E1draig_Brady?= Subject: Re: bug#10472: [PATCH] realpath: fix problems with // handling References: <4F272D64.5010004@draigBrady.com> <1328382356-9521-1-git-send-email-eblake@redhat.com> <4F4264F8.3000608@draigBrady.com> <4F600D44.6070603@redhat.com> <4F60198D.90809@redhat.com> <4F606119.7090406@draigBrady.com> In-Reply-To: <4F606119.7090406@draigBrady.com> X-Enigmail-Version: 1.3.5 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig63590BD681808EB68CED8241" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Spam-Score: -6.9 (------) X-Debbugs-Envelope-To: 10472 Cc: 10472@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig63590BD681808EB68CED8241 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 03/14/2012 03:12 AM, P=E1draig Brady wrote: > On 03/14/2012 04:07 AM, Eric Blake wrote: >> On 03/13/2012 09:15 PM, Eric Blake wrote: >>>> Also doesn't path_prefix() need the same adjustment, >>>> so as to verify --relative-base in the same way? >>> >>> Yes, it looks like it. >> >> In fact, I found another bug, this time present also on Linux: >> >> $ realpath --relative-base=3D/ --relative-to=3D/ / >> / >=20 > This may be a local issue? > $ src/realpath --relative-base=3D/ --relative-to=3D/ / > . Looks like I was testing after some of my modifications to realpath.c; I'm rebasing my tree to add the test before any of my realpath.c changes, so that I can then be avoiding regressions. But it still doesn't explain: $ src/realpath --relative-base=3D/ --relative-to=3D/ / /usr =2E /usr where I would expect 'usr', not '/usr', since /usr is indeed a child of /= =2E >> $ realpath --relative-base=3D/usr/local --relative-to=3D/usr \ >> /usr /usr/local/lib >> /usr >> /usr/local/lib >> >> when it should really output '/usr' (absolute, since it is not a child= >> of /usr/local) and 'local/lib' (which is a file below /usr/local, and = an >> output name relative to /usr). >=20 > Well that was by design. I.E. --relative-base is a guard, > which if either --relative-to or the specified paths go higher, > an absolute name will be output. The documentation wasn't very clear on that point. Either we need to fix the documentation, or consider whether to make 'realpath' fail if --relative-base is not a prefix of --relative-to, or even add another option that allows the behavior I was expecting of making the two orthogonal (that is, where it really is an independent filter - if the path being canonicalized is a child of --relative-base, then output it relative to --relative-to; otherwise output absolute). Also, would it make sense to have --relative-base without --relative-to imply a --relative-to of the same directory? That is, realpath --relative-base=3D/usr /usr would be a useful shorthand for realpath --relative-base=3D/usr --relative-to=3D/usr /usr instead of its current error condition. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig63590BD681808EB68CED8241 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJPYGqfAAoJEKeha0olJ0NqlGMH/ji6fybQ0iNxCYjaeu3MMac1 vhJgtpEnf+yOKIxtneTUntIdkzkLAi5AQtzeHnOx+HQvKLz5NjeUnPvYwXGdLref 4di1MtsFqCVBlc7x61Z1s7+HFgYB/sQXiESuLCKnn5E5Qbj/bf3Qm90szqvveQbj yjpfOEbstQLu43eKNn5g0XcRLCAGjWSwrOwJYbUUnPeyCKHnEcDqKUzLxlYCgvwc s9+B+wccfTc6MGtS+Bw7Lnopi263vExly9K36GE2UB08rGMLcsx+PKv+/EwPiMAj Olz3DdNhqm6af44KHS9lmvBjJ5k3QjE+8EfHdTZMPUQj3UucwUgC7jeoF3KV/tU= =8Eb+ -----END PGP SIGNATURE----- --------------enig63590BD681808EB68CED8241-- From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 14 07:20:00 2012 Received: (at 10472) by debbugs.gnu.org; 14 Mar 2012 11:20:00 +0000 Received: from localhost ([127.0.0.1]:50178 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S7mFL-0003WX-Jm for submit@debbugs.gnu.org; Wed, 14 Mar 2012 07:20:00 -0400 Received: from mail3.vodafone.ie ([213.233.128.45]:32191) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S7mF9-0003WF-0r for 10472@debbugs.gnu.org; Wed, 14 Mar 2012 07:19:58 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkgDAM52YE9tTG0N/2dsb2JhbAAMN7MQgXsDhBsBAQEDATIBRgULCw0BCgklDwJGBg0BBwEBiAG8JYs5hT8Em2OKGYJm Received: from unknown (HELO [192.168.1.79]) ([109.76.109.13]) by mail3.vodafone.ie with ESMTP; 14 Mar 2012 10:49:44 +0000 Message-ID: <4F6077C7.90502@draigBrady.com> Date: Wed, 14 Mar 2012 10:49:43 +0000 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 MIME-Version: 1.0 To: Eric Blake Subject: Re: bug#10472: [PATCH] realpath: fix problems with // handling References: <4F272D64.5010004@draigBrady.com> <1328382356-9521-1-git-send-email-eblake@redhat.com> <4F4264F8.3000608@draigBrady.com> <4F600D44.6070603@redhat.com> <4F60198D.90809@redhat.com> <4F606119.7090406@draigBrady.com> <4F606A9F.7000403@redhat.com> In-Reply-To: <4F606A9F.7000403@redhat.com> X-Enigmail-Version: 1.3.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 10472 Cc: 10472@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On 03/14/2012 09:53 AM, Eric Blake wrote: > On 03/14/2012 03:12 AM, Pádraig Brady wrote: >> On 03/14/2012 04:07 AM, Eric Blake wrote: >>> On 03/13/2012 09:15 PM, Eric Blake wrote: >>>>> Also doesn't path_prefix() need the same adjustment, >>>>> so as to verify --relative-base in the same way? >>>> >>>> Yes, it looks like it. >>> >>> In fact, I found another bug, this time present also on Linux: >>> >>> $ realpath --relative-base=/ --relative-to=/ / >>> / >> >> This may be a local issue? >> $ src/realpath --relative-base=/ --relative-to=/ / >> . > > Looks like I was testing after some of my modifications to realpath.c; > I'm rebasing my tree to add the test before any of my realpath.c > changes, so that I can then be avoiding regressions. But it still > doesn't explain: > > $ src/realpath --relative-base=/ --relative-to=/ / /usr > . > /usr Agreed. --relative-base=/ should essentially be a noop > where I would expect 'usr', not '/usr', since /usr is indeed a child of /. > >>> $ realpath --relative-base=/usr/local --relative-to=/usr \ >>> /usr /usr/local/lib >>> /usr >>> /usr/local/lib >>> >>> when it should really output '/usr' (absolute, since it is not a child >>> of /usr/local) and 'local/lib' (which is a file below /usr/local, and an >>> output name relative to /usr). >> >> Well that was by design. I.E. --relative-base is a guard, >> which if either --relative-to or the specified paths go higher, >> an absolute name will be output. > > The documentation wasn't very clear on that point. Either we need to > fix the documentation, or consider whether to make 'realpath' fail if > --relative-base is not a prefix of --relative-to, or even add another > option that allows the behavior I was expecting of making the two > orthogonal (that is, where it really is an independent filter - if the > path being canonicalized is a child of --relative-base, then output it > relative to --relative-to; otherwise output absolute). > > Also, would it make sense to have --relative-base without --relative-to > imply a --relative-to of the same directory? That is, > > realpath --relative-base=/usr /usr I considered that, and now I'm not sure why I didn't do it. Having both relative-to and relative-base being the same, is the common use case for --relative-base. cheers, Pádraig. From unknown Sun Jun 22 22:41:47 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 11 Apr 2012 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator