GNU bug report logs - #8035
Processing of .. in a file path after going thru symlink

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: spucci <slpnabble@HIDDEN>; dated Mon, 14 Feb 2011 05:50:03 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 8035 <at> debbugs.gnu.org:


Received: (at 8035) by debbugs.gnu.org; 20 Feb 2011 02:50:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Feb 19 21:50:45 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1PqzNl-0007fT-4e
	for submit <at> debbugs.gnu.org; Sat, 19 Feb 2011 21:50:45 -0500
Received: from asmtpout029.mac.com ([17.148.16.104])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <spucci@HIDDEN>) id 1PqzEg-0007Rk-3a
	for 8035 <at> debbugs.gnu.org; Sat, 19 Feb 2011 21:41:22 -0500
MIME-version: 1.0
Content-transfer-encoding: 7BIT
Content-type: text/plain; CHARSET=US-ASCII
Received: from [192.168.1.9] (montevina-mk.surfnetc.com [64.74.213.194])
	by asmtp029.mac.com
	(Oracle Communications Messaging Exchange Server 7u4-20.01 64bit (built
	Nov 21 2010)) with ESMTPA id <0LGW001EGA4O7280@HIDDEN> for
	8035 <at> debbugs.gnu.org; Sat, 19 Feb 2011 18:41:16 -0800 (PST)
X-Proofpoint-Virus-Version: vendor=fsecure
	engine=2.50.10432:5.2.15,1.0.148,0.0.0000
	definitions=2011-02-20_02:2011-02-19, 2011-02-20,
	1970-01-01 signatures=0
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0
	ipscore=0 suspectscore=0 phishscore=0 bulkscore=0 adultscore=0
	classifier=spam
	adjust=0 reason=mlx engine=6.0.2-1012030000 definitions=main-1102190144
Subject: Re: bug#8035: Processing of .. in a file path after going thru symlink
From: Steve Pucci <spucci@HIDDEN>
In-reply-to: <C18D35F8-1104-4696-AD72-EC1476E0477F@HIDDEN>
Date: Sat, 19 Feb 2011 18:41:11 -0800
Message-id: <39D26BEB-205A-469C-B0A1-A02548C4BAC2@HIDDEN>
References: <00lj1bd7ty.fsf@HIDDEN>
	<C18D35F8-1104-4696-AD72-EC1476E0477F@HIDDEN>
To: Glenn Morris <rgm@HIDDEN>, 8035 <at> debbugs.gnu.org
X-Mailer: Apple Mail (2.1082)
X-Spam-Score: -2.6 (--)
X-Debbugs-Envelope-To: 8035
X-Mailman-Approved-At: Sat, 19 Feb 2011 21:50:43 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -2.6 (--)

On Feb 19, 2011, at 6:35 PM, Steve Pucci wrote:

> So I conclude you're right there are other places that do the same thing, apparently.

Well, my experiment didn't intercept the (literally) 98 places that call Fexpand_file_name() directly from the C code, of course...





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8035; Package emacs. Full text available.

Message received at 8035 <at> debbugs.gnu.org:


Received: (at 8035) by debbugs.gnu.org; 20 Feb 2011 02:50:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Feb 19 21:50:46 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1PqzNk-0007fQ-OK
	for submit <at> debbugs.gnu.org; Sat, 19 Feb 2011 21:50:45 -0500
Received: from asmtpout023.mac.com ([17.148.16.98])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <spucci@HIDDEN>) id 1Pqz9Q-0007KL-Tl
	for 8035 <at> debbugs.gnu.org; Sat, 19 Feb 2011 21:35:57 -0500
MIME-version: 1.0
Content-transfer-encoding: 7BIT
Content-type: text/plain; CHARSET=US-ASCII
Received: from [192.168.1.9] (montevina-mk.surfnetc.com [64.74.213.194])
	by asmtp023.mac.com
	(Oracle Communications Messaging Exchange Server 7u4-20.01 64bit (built
	Nov 21 2010)) with ESMTPA id <0LGW008469VBY130@HIDDEN> for
	8035 <at> debbugs.gnu.org; Sat, 19 Feb 2011 18:35:37 -0800 (PST)
X-Proofpoint-Virus-Version: vendor=fsecure
	engine=2.50.10432:5.2.15,1.0.148,0.0.0000
	definitions=2011-02-20_02:2011-02-19, 2011-02-20,
	1970-01-01 signatures=0
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0
	ipscore=0 suspectscore=0 phishscore=0 bulkscore=0 adultscore=0
	classifier=spam
	adjust=0 reason=mlx engine=6.0.2-1012030000 definitions=main-1102190143
Subject: Re: bug#8035: Processing of .. in a file path after going thru symlink
From: Steve Pucci <spucci@HIDDEN>
In-reply-to: <00lj1bd7ty.fsf@HIDDEN>
Date: Sat, 19 Feb 2011 18:35:35 -0800
Message-id: <C18D35F8-1104-4696-AD72-EC1476E0477F@HIDDEN>
References: <00lj1bd7ty.fsf@HIDDEN>
To: Glenn Morris <rgm@HIDDEN>
X-Mailer: Apple Mail (2.1082)
X-Spam-Score: -2.6 (--)
X-Debbugs-Envelope-To: 8035
X-Mailman-Approved-At: Sat, 19 Feb 2011 21:50:43 -0500
Cc: 8035 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -2.6 (--)

On Feb 19, 2011, at 1:37 PM, Glenn Morris wrote:

> This appears to be a feature of expand-file-name (and possibly other
> things). It does seem a little weird that there isn't even an option to
> have a more thorough expansion...

So I ran an experiment, redefining expand-file-name as follows to skip the ".." processing (except in default-directory) and otherwise do the rest:

(or (fboundp 'save-expand-file-name)
    (fset 'save-expand-file-name (symbol-function 'expand-file-name)))
(defun expand-file-name (NAME &optional DEFAULT-DIRECTORY)
  (cond ((string-match "^/" NAME)
         NAME)
        ((string-match "^\\(~[^/]*\\)\\(.*\\)$" NAME)
         (let ((userdir (match-string 1 NAME))
               (rest (match-string 2 NAME)))
           (concat (save-expand-file-name userdir) rest)))
        (t (concat (save-expand-file-name (if DEFAULT-DIRECTORY
                                              DEFAULT-DIRECTORY
                                            default-directory))
                   NAME))))

While this does the trick (it expands only ~ and relative paths and properly leaves the OP path intact), it fails to fix the problem with next-error.  So I conclude you're right there are other places that do the same thing, apparently.

My workaround now is to wrap my build script in a Perl script which rewrites all "../" paths it finds within its output.  So I'm ok, though I'm surprised this hasn't come up before...




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8035; Package emacs. Full text available.

Message received at 8035 <at> debbugs.gnu.org:


Received: (at 8035) by debbugs.gnu.org; 19 Feb 2011 21:37:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Feb 19 16:37:39 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1PquUl-0008TW-Km
	for submit <at> debbugs.gnu.org; Sat, 19 Feb 2011 16:37:39 -0500
Received: from fencepost.gnu.org ([140.186.70.10])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <rgm@HIDDEN>) id 1PquUh-0008T6-GR
	for 8035 <at> debbugs.gnu.org; Sat, 19 Feb 2011 16:37:36 -0500
Received: from localhost ([127.0.0.1]:53928)
	by fencepost.gnu.org with esmtp (Exim 4.71)
	(envelope-from <rgm@HIDDEN>)
	id 1PquUc-0003Y4-0r; Sat, 19 Feb 2011 16:37:30 -0500
From: Glenn Morris <rgm@HIDDEN>
To: spucci <slpnabble@HIDDEN>
Subject: Re: bug#8035: Processing of .. in a file path after going thru symlink
References: <30918394.post@HIDDEN>
X-Spook: S Box ANDVT Kosovo industrial espionage rail gun Israel
X-Ran: qdK4NFw1Io(iF7\KUwJv)W2j^,>tq%@}av$%+-DwSizUk<*#1vfAW/E~,hIswBKl>p`v_5
X-Hue: white
X-Debbugs-No-Ack: yes
X-Attribution: GM
Date: Sat, 19 Feb 2011 16:37:29 -0500
In-Reply-To: <30918394.post@HIDDEN> (spucci's message of "Sun, 13 Feb
	2011 19:05:40 -0800 (PST)")
Message-ID: <00lj1bd7ty.fsf@HIDDEN>
User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Spam-Score: -6.3 (------)
X-Debbugs-Envelope-To: 8035
Cc: 8035 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.3 (------)

spucci wrote:

> When emacs attempts to find a file with "../" as a path component, it
> appears to be "smart" about it and simply remove the previous directory path
> (e.g., "foo/bar/../x" gets converted to "foo/x").  But if bar is a symlink,
> then it doesn't properly find the file.

This appears to be a feature of expand-file-name (and possibly other
things). It does seem a little weird that there isn't even an option to
have a more thorough expansion...




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8035; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 14 Feb 2011 05:49:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 14 00:49:57 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1PorJs-0001bo-GL
	for submit <at> debbugs.gnu.org; Mon, 14 Feb 2011 00:49:57 -0500
Received: from eggs.gnu.org ([140.186.70.92])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <bounces@HIDDEN>) id 1PoocL-00055G-0j
	for submit <at> debbugs.gnu.org; Sun, 13 Feb 2011 21:56:49 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bounces@HIDDEN>) id 1Pooky-00053g-Du
	for submit <at> debbugs.gnu.org; Sun, 13 Feb 2011 22:05:45 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	T_RP_MATCHES_RCVD,
	T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.1
Received: from lists.gnu.org ([199.232.76.165]:42702)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bounces@HIDDEN>) id 1Pooky-00053c-AH
	for submit <at> debbugs.gnu.org; Sun, 13 Feb 2011 22:05:44 -0500
Received: from [140.186.70.92] (port=56429 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1Pookx-00050W-7U
	for Bug-gnu-emacs@HIDDEN; Sun, 13 Feb 2011 22:05:43 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bounces@HIDDEN>) id 1Pookw-00053P-2P
	for Bug-gnu-emacs@HIDDEN; Sun, 13 Feb 2011 22:05:43 -0500
Received: from sam.nabble.com ([216.139.236.26]:48349)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bounces@HIDDEN>) id 1Pookv-00053E-ND
	for Bug-gnu-emacs@HIDDEN; Sun, 13 Feb 2011 22:05:41 -0500
Received: from isper.nabble.com ([192.168.236.156])
	by sam.nabble.com with esmtp (Exim 4.69)
	(envelope-from <bounces@HIDDEN>) id 1Pooku-00036J-DZ
	for Bug-gnu-emacs@HIDDEN; Sun, 13 Feb 2011 19:05:40 -0800
Message-ID: <30918394.post@HIDDEN>
Date: Sun, 13 Feb 2011 19:05:40 -0800 (PST)
From: spucci <slpnabble@HIDDEN>
To: Bug-gnu-emacs@HIDDEN
Subject: Processing of .. in a file path after going thru symlink
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Nabble-From: slpnabble@HIDDEN
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 216.139.236.26
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 199.232.76.165
X-Spam-Score: -5.9 (-----)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Mon, 14 Feb 2011 00:49:56 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -5.9 (-----)


The behavior is general, but it's a particular problem with next-error: 

When emacs attempts to find a file with "../" as a path component, it
appears to be "smart" about it and simply remove the previous directory path
(e.g., "foo/bar/../x" gets converted to "foo/x").  But if bar is a symlink,
then it doesn't properly find the file.  So in compiler output, which
references such files, the next-error function fails to find the file with
the given name. 

mkdir dest 
mkdir dest/subdir 
mkdir src 
ln -s ../dest/subdir src/subdir 
echo "#error This is an error" > dest/foo.c 

Now M-x compile, and give it cc -c src/subdir/../foo.c 

*compilation* buffer has: 
cc -c src/subdir/../foo.c 
src/subdir/../foo.c:1:2: error: #error This is an error 

and do a next-error: Emacs complains it can't find the file.  And if you try
to find-file that file path (src/subdir/../foo.c) it doesn't work either. 
Nor does "emacsclient src/subdir/../foo.c.  I couldn't find an option to
disable this behavior; it seems like there should be one even if the default
continues to be as it is today.

This is Gnu Emacs 23.2.1 I built myself on MacOS X 10.6.6. 

Thanks, 
  Steve 

-- 
View this message in context: http://old.nabble.com/Processing-of-..-in-a-file-path-after-going-thru-symlink-tp30918394p30918394.html
Sent from the Emacs - Bugs mailing list archive at Nabble.com.





Acknowledgement sent to spucci <slpnabble@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8035; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 31 Oct 2014 17:00:04 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.